1 # @noroadsleft's Git aliases
3 [Return to the directory index.](./)
12 sync = "!f() { if [ $(git branch-name) != "master" ]; then git checkout master; fi; git pull upstream master; git push origin master; }; f"
14 # Return the last five commits on the branch, in a more compact format
15 hist = log --pretty=format:\"%C(yellow)%h%Creset %Cgreen%ad%Creset%n %w(100,0,3)%s%d [%an]%n\" --graph --date=iso-local -n 5
16 histm = log --pretty=format:\"%C(yellow)%h%Creset %w(100,0,3)%s%d [%an]\" --graph --date=iso-local -n 5
17 histt = log --pretty=format:\"%C(yellow)%h%Creset %<(88,trunc)%s [%an]\" --graph --date=iso-local -n 5
18 histb = log --reverse --pretty=format:\"- %<(98,trunc)%s [%an]\" --date=iso-local -n 5
21 df = "diff --compact-summary"
24 st = "!git status --short"
26 # Returns the name of the current branch
27 branch-name = "!git rev-parse --abbrev-ref HEAD"
29 # short-form of the above
30 bn = "!git branch-name"
32 po = "push origin ($(git branch-name))"
37 # Show the contents of a numbered stash
40 st-show = "!f() { git stash show stash@{$1} -p; }; f"
42 # Apply a stash, without deleting it from the list of stashes
45 st-copy = "!f() { git stash apply stash@{$1}; }; f"
48 unstage = "reset HEAD"
50 # Restore a file to the state it was in when checked out
51 restore = "checkout --"
53 # Compare local master repo to its upstream branch. If anything is returned, local branch has diverged from upstream.
54 cm = "!f() { git fetch upstream master; git diff $(git branch-name) upstream/master --compact-summary; }; f"
55 cml = "!f() { git fetch upstream master; git diff $(git branch-name) upstream/master; }; f"