Table of Contents

git

The list of helpful git commands was growing too large, so compiling into one page.

Branch

git fetch origin <REMOTE_BRANCH>:<LOCAL_BRANCH>

Submodules

Pull all changes:

git pull --recurse-submodules

Reset changes to submodules (including fast-forwards):

git submodule deinit -f .
git submodule update --init

# From old page

Initial setup

Small editing and cleanups

Patching

Changing history

Signing

By default, GPG keys are used for signing commits (manually using -S flag). As of Git 2.34 (Nov 2021), SSH keys can also be used to sign commits.

Misc

.gitignore
[core]
autocrlf = false
 
[alias]
adog = log --all --decorate --oneline --graph
.gitconfig
[user]
        name = pyuxiang
        signingkey = ...
[commit]
        gpgsign = true
[gpg]
        format = ssh
[alias]
        # Personal
        adog = log --all --decorate --oneline --graph
        addw = -c interactive.diffFilter='git diff --color=always --word-diff' add -p
        diffw = diff --color-words='[^[:space:]]|([[:alnum:]]|UTF_8_GUARD)+'
        diff-staged = diff --cached
 
        # Common operations
        remove = reset --mixed HEAD
        uncommit = reset --soft HEAD~
        recommit = commit --amend
 
        # Get lists of stuff
        branches = branch -a
        tags = tag -l --sort=v:refname
        stashes = stash list
        remotes = remote -v