1.get the git repository
git init (use git manage the project, this command will generate
the .git directory)
git clone [url] [directory](checkout the repository from the specified
url )
2.record the update
git status
git add [file name] (untracked to staged / modified to staged)
git checkout [file name](discard the changes in working directory)
git diff [file name](compare the working directory with staged file)
git diff --cached / --staged [file name](compare the staged file with
the last commit snapshot)
git commit [file name](commit staged file)
git commit -a [file name](commit tracked file)
git rm [file name](remove the staged file)
git rm --cached [file name](remove the staged file but leave it in the
working directory)
git mv file_from file_to (modify file name in the git)
3.view the commit history
git log (list all the commit log order by the commit time)
git log -p -2(-p list the difference between every commit
-2 display the recent two record)
git log --stat(display the modify like statistics)
git log --pretty=format:"%h - %an, %ar : %s"(display the record in the
specified format)
gitk(graphical tool)
4.destruction operation
git commit --amend(modify the last commit information)
git reset HEAD <file>(return the staged file back to untracked files)
5.how to use remote repository
git remote (display remote repository name)
git remote -v (display the remote repository url)
git remote add [shortname] [url] (add a new remote repository )
git fetch [remote-name](fetch data from the remote repository )
git push [remote-name] [branch-name] (push data to the remote
repository)
git remote show [remote-name] (display remote repository detail
information)
git remote rename [file_from] [file_to](change the remote repository
name)
git remote rm paul [file_name](remove the remote repository)
6.tag
git tag(display all tag)
git tag -a [tag name] -m [tag information](-a annotated tag -m
explain the tag)
git show [tag name]
7.misc
git branch -a(list all branch)
git branch [branch name](create a new branch)
git checkout [branch name] (switch the branch)
git checkout -b [branch name](switch to a new branch)
git branch -d [branch name](delete the specified branch)
git merge [branch name] (merge this branch to the current branch)
git mergetool -t tkdiff (use merge tool tkdiff to merge the conflict
file)