-
Notifications
You must be signed in to change notification settings - Fork 3
Git Commands
This page is the Plain English programming language's Git Cheat Sheet.
The Getting Started page describes how to get started using git, GitHub, and this repository. The Pro Git book explains the commands shown below, especially in chapters 2.2 Recording Changes to the Repository, 2.3 Viewing the Commit History, and 2.4 Undoing Things
The Branches page explains the three major branches in this repository: The master branch, the proposed branch, and the development branch.
You can Move a Branch Backwards, or Fast-Forward a Local Branch, or Push a Branch to GitHub. To retrieve old versions of files and folders, you can create a Temp Branch on an Earlier Commit.
git
can be run from a Linux shell, with the current directory set to whichever directory contains the English code.
git status
shows which files (except the ones listed in .gitignore
) are not up-to-date in the repository.
git add <(possibly wildcarded) filename>
tells git that the current version of the file should be staged. Staged files will be pushed into the repository during the next commit.
git reset HEAD <(possibly wildcarded) filename>
subtracts a file from the staging area.
git rm <(possibly wildcarded) filename>
tells git that a file that has been deleted from the working directory should be staged for removal from the repository's latest set.
git rm --cached <(possibly wildcarded) filename>
Ditto, but for files that have not been deleted from the working directory.
git diff
shows diffs between the working directory and what has been staged (ignoring whether the files have been committed yet).
git diff --staged
shows diffs between the working directory and what has been committed.
git commit -m "<commit note>
" Commits the changes from staging into the repository, with the commit note.
git commit
Ditto, but uses a text editor to prompt for the commit note. Also shows (as comments that are not part of the commit note) the output from git status in the text editor.
git commit -v
Ditto, but shows the output of git diff --staged
instead of git status
.
git commit -a
Ditto, but allows skipping the git add
step(s) by automatically staging all tracked files that are not up-to-date in the repository. It ignores the files listed below.
git commit --amend
Retroactively fix the most recent commit, and/or the commit message.
git checkout -- <(possibly wildcarded) filename>
copy a file from the repository to the working directory, overwriting the file(s) (if already present) in the working directory.
Reporting the change log:
git log
Show summary of changes, most recent first.
git log -p
Ditto, with diffs.
git log -p --word-diff
Much finer diffs; suitable for comparing .civ files.
git log --stat
Summarizes changes as count(s) of file(s) added, changed, or removed.
To format the log output:
git log --pretty=oneline
git log --pretty=short
git log --pretty=full
git log --pretty=fuller
git log --pretty=format:"%h - %an, %ad : %s"
git log --pretty=format:"%h - %cn, %cd : %s"
git log --name-status
git log -<n>
shows the most recent log entries.
To show the log entries since (or until) a particular time:
git log --since <n>.weeks
git log --since "<date>"
git log --until <n>.weeks
git log --until "<date>"
git log <any other options> <filepath as last option>
gitk
GUI version of git log