Never think that I'll have a chance to write down a cheat sheet for Git before, but this is a special note for my lovely student ;).
Initializing Git in Working Foldergit init
Cloning Git Repogit clone [repository name]
Viewing Statusgit status
Viewing Loggit log
Adding File to Staginggit add [file name]
Committing File to Committed Stategit commit -m "message"
Removing Filegit rm [filename]
This will remove a file from being tracked by Git, and will physically delete it too.git rm --cahced [file name]
This will remove a file from being tracked by Git, but will not physically delete it.
Renaming A Filegit mv [old file name] [new file name]
Ignoring Changes Made to A Particular Filegit checkout [file name]
Creating New Branchgit branch [branch name]
List All Branchgit branch
Use -a option to show remote branches.
Removing A Branchgit branch -d [branch name]
Use -D option for force delete.
Switching between Branchgit checkout [branch name]
Switching between Branch (create if target branch did not exist)git checkout -b [branch name]
Creating and Checking out The Branch with Remote Trackinggit checkout --track -b [branch name] origin/[branch name]
Showing The Changes Made on A Filegit diff [file name]
Merging A Branchgit merge [branch name]
This will merge [branch name] into the current branch.
Rebasing A Branchgit rebase [branch name]
Rebase current branch over [branch name].
Soft Resetinggit reset --soft HEAD~[n]
Step the commit back to for [n] commits while keeping the changes made within [n] commits in staging state.
Normal Resetinggit reset HEAD~[n]
Step the commit back for [n] commits and leave the changes made within [n] commits in unstaging state.
Hard Resetinggit reset --hard HEAD~[n]
Step the commit back for [n] commits and discard all changes made within [n] commits.
Rewriting Recent Commit Messagegit commit --amend -m "new commit message"
Stashing The Changegit stash save "message"
Unstashing The Changegit stash pop
Showing Stash Listgit stash list
Pushing to Remotegit push origin [remote branch name]
Pulling from Remote Branch And Merge to Local Branchgit pull origin [remote branch name]
This will pull and merge the commits from remote branch to local branch
Pulling from Remote Branch And Rebase to Local Branchgit pull --rebase origin [remote branch name]
This will pull and rebase the commits from remote branch to local branch