2. Content
● What is git? - 30 seconds
● How it works? - 2 minutes
● Github flow - 3 minutes
● Frequently Used Commands - 2 minutes
● Confusions on Undo- 2 minutes
● Useful links - 30 seconds
3. Git
● Distributed version control system
Although git allows to have multiple remote repositories, usually we maintain only one remote
repository, that is ‘origin’.
Associated command: git remote -v
9. Frequently Used Commands
● If you have done so many unnecessary changes in different files and now you want to discard all the changes ( before
working at cool mind ) :
git reset --hard
● Another most used command that is very useful when did commit but that was a mistake. What will you do?
If you want to remove your last commit that has not been pushed yet:
git reset --hard HEAD^
● To view unpushed git commits
git log origin/master..HEAD
● To create a local branch that will track remote branch
git checkout -t origin/branchname
● To see all commits of someone
git log --author=Jon
● To see all commits since last 2 weeks
git log --since=2.weeks
● To see the diff of a file which has already been added to stage
git diff --cached example.txt
10. Confusions
Undo:
Action Command Output
M git checkout filename -
M > S git reset HEAD filename M
M > S > C git reset --soft HEAD^ S
M > S > C git reset --mixed HEAD^ M
M > S > C git reset --hard HEAD^ -
M > S > C > P git reset --hard HEAD^
git push -f origin branch-name
-
M = Modified
S = Staged
C = Committed
P = Pushed