Skip to main content

Posts

Showing posts with the label Git

GIT : How to remove untracked files in git

There might be several conditions where you have started editing a file in git but then you realize its not needed any more and want to roll it back.  Such files will be showing in untracked files list in git as show below when you run git status command. Today we will learn how to remove such untracked files in git.  To fix it you can run the below command :  git clean -f 

How to see remote changes before doing Git Pull

Before going through the steps, lets first understand what is the purpose of GIT Pull ? In simple terms, GIT PULL is a GIT Command which access the Remote repository and checks which all files were modified or created and is different from the local repository. Once it finds that info, it downloads those file to your local repository.  Technically speaking, GIT Pull runs 2 commands i.e GIT Fetch and GIT Merge in background. GIT Fetch downloads the latest change to the local repository while GIT Merge merges the remote content refs and heads to new local merge commit. so you can say the below is same : GIT Pull <remote> -or- GIT Fetch <remote> GIT Merge origin/master So lets begin with the steps on how to see the remote (origin/master) changes before doing Git Pull :  Git fetch origin Git log master..origin/master Git diff master..origin/master Git pull / Git merge origin/master Happy Leaning! How to get started with GIT in Windows : Check out here

How to use git in windows

1. Download GIT package for windows . Click Here 2. Once downloaded install the package as given below : 3. Once installation is complete, you can open git by using Git cmd, Powershell or Command Prompt. 4. Now we have to Clone our Git Repo from GIT Bucket, GitHub, GitLab etc. I have my repo in Github so lets see how to clone it from Github. 5. Login to your github account, you will see the clone url to clone the git repo. It would be something like :  https://github.com/<Username>/<Repository Name>.git 6. Once you got the URL.Open git cmd or powershell, and give the command as shown below : git clone https://github.com/<Username>/<Repository Name>.git 7. Now you can see that Git Folder got created on the specified directory. so we are done, now simply put you scripts and push them to the Central git repository. 8. Some useful git commands : git status git add git pull git commit git push git remote git log git fetch Any