Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.
Below are git commands that every developer should be aware and use day to day.
git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the
The modifications stashed away by this command can be listed with
git stash list, inspected with
git stash show, and restored (potentially on top of a different commit) with
git stash apply.
Rebase is one of two Git utilities that specializes in integrating changes from one branch onto another. The other change integration utility is
git merge. Merge is always a forward moving change record. Alternatively, rebase has powerful history rewriting features.
git cherry-pick is a powerful command that enables arbitrary Git commits to be picked by reference and appended to the current working HEAD. Cherry picking is the act of picking a commit from a branch and applying it to another.
git reset –hard
This command resets the current branch to the commit you specify (
--hard means to discard both index and working tree changes).
git reset --hard HEAD^ resets the current branch one commit backward, while
git reset --hard HEAD just discards all local changes.
git merge –squash <branch>
This command merges all commits on <branch>. Note that
git merge --squash prepares the merge but does not actually make a commit. You will need to execute
git commit to create the merge commit.
git has already prepared the commit message to contain the messages of all the squashed commits.