This appendix provides an alphabetical list of the Git commands cited in this Web page, along with brief descriptions of what the commands do.
Note that you may always use either ‘git help command’ or ‘git command --help’ to get short, man-page style help on how to use any given Git command.
Add a file to the list of files to be committed.
View existing branches, or delete a branch. Most useful options: -a and -d.
Checkout an existing branch, create a new branch, or checkout a file to reset it. Use the -b option to create and checkout a new branch in one operation.
Clone (make a new copy of) an existing repository. You generally only need to do this once.
Commit changes to files which have been staged for committing with ‘git add’. This makes your changes permanent, in your local repository only. To publish your changes to an upstream repo, you must use ‘git push’.
Display and/or change global and/or local configuration settings.
Show a unified-format diff of what’s changed in the current directory as of the last commit. It helps to have Git configured to use its builtin pager for reviewing diffs (see Configuring git).
Use a “tool” (usually a GUI-based program) to view differences, instead of the standard textual diff as you’d get from ‘git diff’.
Update your local copy of the upstream’s branches. That is, update the various ‘origin/’ branches. This leaves your local tracking branches unchanged. With the --prune option, this removes any copies of stale ‘origin/’ branches.
Create a series of patch files, one per commit not on the original branch from which you started.
Run a “garbage collection” pass in the current repository.
This can often reduce the space used in a large repo. For
gawk it does not make that much difference.
Print a man-page–style usage summary for a command.
Show the current branch’s commit log. This includes who made the commit, the date, and the commit message. Commits are shown from newest to oldest.
Merge changes from the named branch into the current one.
When in your local tracking branch
run ‘git fetch’, and then merge from
Push commits from your local tracking branch
origin/xxx and on to branch
in the upstream repo. Use ‘git push -u origin --delete xxx’ to delete
an upstream branch. (Do so carefully!)
Rebase the changes in the current purely local branch to
look as if they had been made relative to the latest
commit in the current upstream branch (typically
This is how you keep your local, in-progress changes up-to-date
with respect to the original branch from which they were started.
Restore the original state of the repo, especially with the --hard option. Read up on this command, and use it carefully.
Show the status of files that are scheduled to be committed, and those that have been modified but not yet scheduled for committing. Use ‘git add’ to schedule a file for committing. This command also lists untracked files.