1 # @noroadsleft's Git aliases
3 [Return to the directory index.](./)
14 # Check out a Pull Request
15 cop = "!f() { git fetch upstream pull/$1/head:pr/$1; git checkout pr/$1; }; f"
18 sync = !git checkout master && git fetch upstream 2> /dev/null && git pull -n upstream master && git push origin master
20 # Return the abbreviated SHA-1 of the last three commits, oldest to newest
21 rl = rev-list -n 3 --abbrev-commit --reverse HEAD
23 # Add remote repo (for sending PRs to other forks, or checking out someone else's developments)
24 ar = "!f() { git remote add $1 https://github.com/$2/qmk_firmware.git; }; f"
26 # Return the last five commits on the branch, in a more compact format
27 hist = log --pretty=format:\"%C(yellow)%h%Creset %Cgreen%ad%Creset %Cblue[%an%Cgreen% GK%Cblue]%C(yellow)%d%Creset%n %w(100,0,2)%s%n\" --graph --date=iso-local -n 5
28 histt = log --pretty=format:\"* %C(yellow)%h%Creset %<(58,trunc)%s %Cblue%>(18,trunc)%an%Cgreen% G?%Creset @ %Cgreen%ad%Creset\" --date=iso-local -n 5
29 histb = log --reverse --pretty=format:\"- %Cblue%>(20,trunc)%an %Creset%<(97,trunc)%s\" --date=iso-local -n 5
31 # Follow a file's filename history
32 follow = log --follow --name-only --pretty=format:\"%C(yellow)commit %H%Creset%d\nAuthor: %an <%ae>\nDate: %ad%n%n %s%n\" --date=iso-local
35 df = "diff --compact-summary"
37 # List all the files changed in a commit
38 dt = "diff-tree --no-commit-id --name-only -r"
41 st = "!git status --short --untracked-files=no"
43 # Returns the name of the current branch
44 branch-name = "!git rev-parse --abbrev-ref HEAD"
45 bn = "!git branch-name" # short-form of the above
47 # Compare commit counts between current branch and QMK master
48 cc = "!f() { git fetch upstream; echo \"
\e[0;32m$(git branch-name)
\e[0m vs.
\e[0;31mupstream/master
\e[0m\"; git rev-list --left-right --count $(git branch-name)...upstream/master; }; f"
51 po = "push origin $(git branch-name)"
57 unstage = "reset HEAD"
59 # Restore a file to the state it was in when checked out
60 restore = "checkout --"
62 # Compare local master repo to its upstream branch. If anything is returned, local branch has diverged from upstream.
63 cm = "!f() { git fetch upstream master; git diff $(git branch-name) upstream/master --compact-summary; }; f"
64 cml = "!f() { git fetch upstream master; git diff $(git branch-name) upstream/master; }; f"
66 # Delete a branch from local and remote
67 del-branch = "!f() { git branch -d $1; git push origin :$1; git fetch -p origin; }; f"
69 # Rebase with signatures
70 rbv = rebase --exec 'git commit --amend --no-edit -n -S' -i
72 # Force push without overwriting established history
73 pushf = push --force-with-lease