-
Notifications
You must be signed in to change notification settings - Fork 3
Git commands and syntax
Reference: https://developers.google.com/style/code-syntax
Cheatsheet: https://training.github.com/downloads/github-git-cheat-sheet/
Text without brackets or braces.
command
command --argument
Text enclosed in square brackets.
command [--argument]
If there's more than one optional argument, each item is enclosed in its own set of square brackets.
command [--argument1] [--argument2]
If only one of the specified items should be chosen, the items are enclosed inside curly brackets (aka. braces), with vertical bars (aka. pipes) separating the options. There can be more than two mutually exclusive choices, separated from each other by pipes.
command {--argument1 | --argument2}
command {-a | --argument}
command {--required1 --also-required1 | --or-required2 [--optional2]}
Arguments that can have multiple values specified by the user are indicated with an ellipsis (...) .
command [--repeatable-argument ...]
User provided information is enclosed in angle brackets (aka. chevrons).
command --argument <user-input>
For the complete list of all commands, see https://git-scm.com/docs.
| Category | Command | Description |
|---|---|---|
| Setup and Config | git | Git |
| git-config | Get and set repository or global options | |
| git-help | Display help information about Git | |
| git-bugreport | Collect information for user to file a bug report | |
| Getting and Creating Projects | git-init | Create an empty Git repository or reinitialize an existing one |
| git-clone | Clone a repository into a new directory | |
| Basic Snapshotting | git-add | Add file contents to the index |
| git-status | Show the working tree status | |
| git-diff | Show changes between commits, commit and working tree, etc | |
| git-commit | Record changes to the repository | |
| git-notes | Add or inspect object notes | |
| git-restore | Restore working tree files | |
| git-reset | Reset current HEAD to the specified state | |
| git-rm | Remove files from the working tree and from the index | |
| git-mv | Move or rename a file, a directory, or a symlink | |
| Branching and Merging | git-branch | List, create, or delete branches |
| git-checkout | Switch branches or restore working tree files | |
| git-switch | Switch branches | |
| git-merge | Join two or more development histories together | |
| git-mergetool | Run merge conflict resolution tools to resolve merge conflicts | |
| git-log | Show commit logs | |
| git-stash | Stash the changes in a dirty working directory away | |
| git-tag | Create, list, delete or verify a tag object signed with GPG | |
| git-worktree | Manage multiple working trees | |
| Sharing and Updating Projects | git-fetch | Download objects and refs from another repository |
| git-pull | Fetch from and integrate with another repository or a local branch | |
| git-push | Update remote refs along with associated objects | |
| git-remote | Manage set of tracked repositories | |
| git-submodule | Initialize, update or inspect submodules | |
| Inspection and Comparison | git-show | Show various types of objects |
| git-log | Show commit logs | |
| git-diff | Show changes between commits, commit and working tree, etc | |
| git-difftool | Show changes using common diff tools | |
| git-range-diff | Compare two commit ranges (e.g. two versions of a branch) | |
| git-shortlog | Summarize git log output | |
| git-describe | Give an object a human readable name based on an available ref | |
| Patching | git-apply | Apply a patch to files and/or to the index |
| git-cherry-pick | Apply the changes introduced by some existing commits | |
| git-diff | Show changes between commits, commit and working tree, etc | |
| git-rebase | Reapply commits on top of another base tip | |
| git-revert | Revert some existing commits | |
| Debugging | git-bisect | Use binary search to find the commit that introduced a bug |
| git-blame | Show what revision and author last modified each line of a file | |
| git-grep | Print lines matching a pattern |
Group 39 Cream Cat - Andy Huang, Sunho Jung, Wenxin Pan, Kevin Yee
2021 Semester 1, CompSci 732 / SoftEng 750 - University of Auckland