GIT常用命令总结
GIT内容较多使用方法较为细致,因此本文主要用作概要目录性质,以便以后使用时查询方便。
-
Getting and Creating Projects
| command | describe |
|---|---|
| init | Create an empty Git repository or reinitialize an existing one |
| clone | Clone a repository into a new directory |
-
Basic Snapshotting
| command | describe |
|---|---|
| add | Add file contents to the index |
| status | Show the working tree status |
| diff | Show changes between commits, commit and working tree, etc |
| commit | Record changes to the repository |
| reset | Reset current HEAD to the specified state |
| rm | Remove files from the working tree and from the index |
| mv | Move or rename a file, a directory, or a symlink |
-
Branching and Merging
| command | describe |
|---|---|
| branch | List, create, or delete branches |
| checkout | Switch branches or restore working tree files |
| merge | Join two or more development histories together |
| mergetool | Run merge conflict resolution tools to resolve merge conflicts |
| log | Show commit logs |
| stash | Stash the changes in a dirty working directory away |
| tag | Create, list, delete or verify a tag object signed with GPG |
-
Sharing and Updating Projects
| command | describe |
|---|---|
| fetch | Download objects and refs from another repository |
| pull | Fetch from and integrate with another repository or a local branch |
| push | Update remote refs along with associated objects |
| remote | Manage set of tracked repositories |
| submodule | Initialize, update or inspect submodules |
-
Inspection and Comparison
| command | describe |
|---|---|
| show | Show various types of objects |
| log | Show commit logs |
| diff | Show changes between commits, commit and working tree, etc |
| shortlog | Summarize git log output |
| describe | Give an object a human readable name based on an available ref |
-
Patching
| command | describe |
|---|---|
| apply | Apply a patch to files and/or to the index |
| cherry-pick | Apply the changes introduced by some existing commits |
| diff | Show changes between commits, commit and working tree, etc |
| rebase | Reapply commits on top of another base tip |
| revert | Revert some existing commits |