Version control is an important concept in Software Engineering because deleloping software is an accumulative work and you need to properly manage all the files and their changes. With a good Version Control System (VCS), you can compare changes over time or revert the entire project back to a previous state. It facilitates collaboration within a group of people on the same project in different ways simultaneously.
Git is a most popular VCS at present. The image below shows the commands that you might have been familiar with. Git has many more practical functions and here lists some.
Initializing a Repository
$ git init
$ git init <PROJECT-NAME> # make a new directory
$ git clone <REMOTE-REPO-URL> # download project from url
$ git submodule add <URL> # add a repository as subdirectory
$ git submodule init # initialize submodule's local configuration
$ git submodule update # fetch the repo
Recording Changes to Repository
$ git add <FILE>/<FOLDER>/. # stage new files
$ git add -p <FILE> # selectively stage new files
$ git rm <FILE> # stage removals
$ git mv <FILE_FROM> <FILE_TO> # stage renamings
$ git update-index --assume-unchanged <FILE> # assume file unchanged
$ git commit -m <MSG> # commit file changes from staging area to repository
$ git commit --amend ... # change last commit
$ git commit -a ... # skip staging area and commit changes directly from workspace
$ git reset HEAD <FILE> ... # unstage files
$ git checkout -- <FILE> # revert files back to its latest revision
$ git stash <-u> # hide staged/untracked changes to stack to make workspace clean
$ git stash list # check stash list
$ git stash apply <stash@{2}> # apply last stashed change or a selected one
$ git stash pop # apply stashed change and drop it from the stack
Working with Remotes
$ git remote -v # show all remote repos
$ git remote add <REPO> <URL> # add new remote repo
$ git remote show origin # remote repo's info
$ git fetch <REMOTE-REPO> # sync local repo with remote
$ git merge <REMOTE>/<BRANCH> # merge local with remote
$ git pull <REMOTE> <BRANCH> # pull = fetch + merge
$ git push <REMOTE> <BRANCH> # save changes to remote repo
$ git push -f <REMOTE> # save changes to remote even if having conflict
Branch and Tag
$ git branch <-a/-r> # list local/all/remote branches
$ git branch <NEW> <COMMIT> # create new branch/based on commit
$ git checkout <BRANCH> # switch to a branch
$ git branch -d/-dr <BRANCH> # delete a local/remote branch
$ git merge <BRANCH> # merge a branch to the current one. sometimes you have to
# resolve merge conflict manually and submit the commit.
$ git rebase <BRANCH> # move changes of current branch onto top of a selected one
$ git tag # list tags
$ git tag <NEW> <COMMIT> # create new tag/based on commit
$ git tag -a v1.4 -m "my 1.4" # add annotation
Checking Information
$ git status # status of modified files
$ git log # history of current branch
$ git log -3 --all # the last 3 records, all branches
$ git log --stat # show statistics for files modified in each commit
$ git log --pretty=format:"%h %ad %s (%an)" --date=short | tail -n 10
# first 10 commits, other pretty formats: --oneline --decorate --graph
$ git show <COMMIT> # all file changes of a commit
$ git show <COMMIT>:<FILE> # a file change of a commit
$ git diff # difference between workspace and staging area
$ git diff HEAD # difference between uncommitted files and the latest commit
$ git diff --cached # difference between staging area and the latest commit
$ gid diff <COMMIT1> <COMMIT2> # difference between two commits
$ git blame <FILE> # the formation of current file (when and by whom)
$ git shortlog -sn # show users and corresponding count of commits
Reverting to and Rewriting History
$ git reset <COMMIT> # HEAD is reset and files are unstaged
$ git reset <COMMIT> -- <FILE>
$ git reset --soft <COMMIT> # HEAD is reset and files are still staged
$ git reset --hard <COMMIT> # HEAD is reset and changes are removed
$ git rebase -i HEAD~3 # can reorder commits, change message, squash or split commits
More: git web, including references and the Pro Git book, also explaining the mechanism and commands in detail.