Category Archives: Git

Fetching colleague’s fork on Github

I am currently using Github and all project members have forked the main repository into private repository. Now the problem is that I need to review my colleagues code committed in his branch inside his forked repository. So to do this I found out a good article that showed me exactly how to do that. I used the following approach.

git remote add my-colleague

git fetch my-colleague

git checkout -b my-colleague-branch --track my-colleague/branch

After I do this I can see all the work done by my colleague and I can switch back to my branch anytime.

Delete Untracked File Using Git

Sometimes we want to clean out our Git workspace and remove any file which is untracked. A hard reset usually does the job for modified files as shown below:
git reset --hard

But hard reset doesn’t fit in case of untracked files. The following command will do the job:
git clean -d -fx ""

-x means ignored files are also removed as well as files unknown to git.

-d means remove untracked directories in addition to untracked files.

-f is required to force it to run.


Configuring Git user name and email

Since I like working using terminal I prefer to do all my operations of git from the command prompt. The first prerequisite to this is to have my name and email configured. This few commands are required to do this simple operation:

To set the name and email:

git config --global "Your Name"
git config --global "Your Email"

To view the name and email which is known to git execute the same commands without any parameter as shown below:

git config --global
git config --global