Every person who is in tech field has or will use git in their workflow. Git and Github are amazing tools for version control and helps you to collaborate with other people working on the same projects. The basics of the git contains pull requests, commits,forks, merges,cloning etc. Now we are going to discuss topics beyond these basics that helps in making your workflow efficient.
1.Git bisect:
Git bisect is generally used for large code bases where a number of commits takes place. In such bases if a bug occurs , it becomes difficult to trace the origin of the bug. This is where the git bisect tool becomes valuable. All you have to do is find a commit where the code works and a commit where it does not , and you don't have to do this manually with the commits. You can use git log tool to find a good commit and a bad commit. After setting a margin, the git bisect starts a step and step elimination process to find the bad commit.
You can start the git bisect with git bisect start
command and end it with git bisect reset
command.
2.Git blame:
First of all, don't get fooled by the name. Git blame is a very useful command to find out the history behind a line of code. If you are working with many people and someone changed something in the code base and you want to know who did it, you can use git blame.
You can initiate git blame with git blame fileName
.
There are other aliases for git blame like git show
, git who
, git fame
3.Git stash:
Git stash allows you to save your code without committing it into a branch. This is helpful when you are working on different branches and want to move from branch to other. Git stash records the work in your current directory and gives you a clean directory to work with.
You can initialize git stash
with git stash command and it saves your current state in a stack. If you want to restore the last saved state, you can use git stash pop
command.
Top comments (0)