Skip to content

using Git

Install Git, then set your user name and email address with git config --global user.email "foo@bar.baz" && git config --global user.name "foobarbaz", where foo@bar.baz is your email and foobarbaz is your user name.

Create a repository in a local directory, ideally including a README.md and a LICENSE.md file, and a .gitignore file if necessary. Navigate to the repository's directory with cd, use git init to create an empty Git repository, then use git add . to update the index. Use git commit -m "Initial commit" to establish an initial Git commit with the message Initial commit. Single-line commit messages act as summaries, the convention is to write using imperative mood, start with a capital letter, and end without a period1.

To ignore an already-committed directory or file, add it to .gitignore, commit the .gitignore file, then use git rm --cached foobar, where foobar is the directory or file to be ignored. The directory or file will not be deleted, and it will now be ignored by Git.

action script representation notes
amend the most recent commit message before pushing it to a remote repository git commit --amend -m "foobar" foobar represents the new message
create a commit without a commit message git commit -a --allow-empty-message -m ''
create a maximally-compressed zip archive of the local repository git archive --format=zip -9 -o /foo/bar/baz.zip HEAD /foo/bar/baz.zip represents the path to the zip archive file.
detect changes git ls-files -m
download a copy of all the versioned data in a Git repository git clone git://foo.bar/baz.git /foo/bar2 git://foo.bar/baz.git represents the URI of the Git repository, and /foo/bar represents the directory the data will be downloaded to. If /foo/bar is omitted, the data will be downloaded to a newly-created baz directory.
get the commit count across all branches git rev-list --all --count
list all commits in the commit history of branches and tags git log --all
list all commits with deleted files git log --diff-filter=D --summary
rename the shortname of a remote git remote rename foo bar foo represents the original shortname and bar represents the new shortname.
set the default text editor git config --global core.editor "foobar" foobar represents the command that will launch the text editor from the command line.
verify the data integrity of a Git repository git fsck fsck is an abbreviation of file system consistency check.3 The --full option is enabled by default.
view a specified commit git show foobar foobar represents the 40-character commit object name.

GitHub-specific information

action script representation notes
change the remote repository on GitHub git remote set-url baz https://github.com/foo/bar.git foo represents the username, bar represents the repository name, and baz represents the shortname of the remote.
connect a local repository with a remote repository on GitHub git remote add baz https://github.com/foo/bar.git foo represents the username, bar represents the repository name, and baz represents the shortname of the remote.
pull any changes from the connected remote repository on GitHub and add those changes to the local repository git pull baz master baz represents the shortname of the remote.
push the local repository to the connected remote repository on GitHub git push -u baz master baz represents the shortname of the remote. Enter the user's GitHub username and password at the resulting prompt. It may be useful to first simulate the Git command by including the “dry run” -n option, as with git push -n -u baz master.

licensing

No rights reserved: CC0 1.0, excepting the section below.

prior work

less-freely-licensed section

To discard unstaged changes that are not in the index, use git stash save --keep-index --include-untracked, then drop the stash with git stash drop.

action script representation notes
list all of the already committed files being tracked by one's Git repository git ls-tree --full-tree -r HEAD
show files managed by Git git ls-files It is limited to the current directory and any subdirectories.
undo the initial Git commit by deleting the branch one is on git update-ref -d HEAD

licensing

Some rights reserved: CC BY-SA 3.0. Includes significant content from:

with changes made.

prior work