Git

Git submodule update

git submodule update --init --recursive

Upload new branch to origin remote

git push -u origin <new_branch>

List files to be committed

git status

Show unstaged changes

git diff

Show changes using file diff tool

git difftool

Show staged changes

git diff --staged

Commit (permanently record) staged changes

git commit -m "message"

Create a ‘fixup!’ comit for older commit (to be autosquashed)

git commit --fixup <sha1>

Create a ‘squash!’ commit for older commit (to be autosquashed)

git commit --squash <sha1>

List all local branches

git branch

Print name of current branch

git rev-parse --abbrev-ref HEAD

Create new branch and switch to it

git checkout -b <new_branch_name>

Create new branch while staying on current one

git branch <new_branch_name>

Merge other branch into current one

git merge <other_branch>

Perform interactive rebase

git rebase -i <other_branch>

Perform interactive rebase with autosquash

git rebase -i --autosquash <other_branch>

Rename a branch

git branch -m <old_name> <new_name>

Delete a branch

git branch -d <old_name>

Apply an existing commit to current branch (cherry-pick)

git cherry-pick <sha1>

Delete a file and stage deletion

git rm <file_name>

Stage file deletion from repo, but keep it locally

git rm --cached <file_name>

Stage file moving or renaming

git mv <old_filepath <new_filepath>

Stash (temporarily put away) uncommitted changeset

git stash

Restore most recent stashed changeset

git stash pop

List all stashed changesets

git stash list

Delete last stashed changeset

git stash drop

Edit last commit with new staged changes

git commit --amend

Undo (discard) last commit

git reset HEAD~

Undo (discard) last 3 commits

git reset HEAD~3

Revert previous commit by creaing opposite commit

git revert <sha1>

Create new tag

git tag -a <tag_name>

List tags

git tag

Show history for current branch

git log

Show history, one line per commit

git log --oneline

Show history, with merged branch graph

git log --graph

Show history for specific file

git log --follow <file_path>

Show specific commit (contents and metadata)

git show <sha1>

Discard uncommitted changes

git reset --hard

Delete all untracked files and directories

git clean -fd

Launch GitWeb (requires supported web server)

git instaweb

Stop GitWeb

git instaweb stop

Launch official Git GUI

gitk