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 https://github.xyz.com/my-colleague/project.git
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.
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.
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 user.name "Your Name"
git config --global user.email "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 user.name
git config --global user.email