summaryrefslogtreecommitdiffstats
path: root/keyboards/kc60/keymaps/noroadsleft/readme_git.md
blob: 585d9c8909c8a8fcff95685d5748f74850b476cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# @noroadsleft's Git aliases

[Return to the directory index.](./)

```
[alias]
    # change branches
    co = checkout
    cob = checkout -b

    # sync master
    sync = "!f() { if [ $(git branch-name) != "master" ]; then git checkout master; fi; git pull upstream master; git push origin master; }; f"

    # Return the last five commits on the branch, in a more compact format
    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
    histm = log --pretty=format:\"%C(yellow)%h%Creset %w(100,0,3)%s%d [%an]\" --graph --date=iso-local -n 5
    histt = log --pretty=format:\"%C(yellow)%h%Creset %<(88,trunc)%s [%an]\" --graph --date=iso-local -n 5
    histb = log --reverse --pretty=format:\"- %<(98,trunc)%s [%an]\" --date=iso-local -n 5

    # compact diff
    df = "diff --compact-summary"

    # Short-form status
    st = "!git status --short"

    # Returns the name of the current branch
    branch-name = "!git rev-parse --abbrev-ref HEAD"

    # short-form of the above
    bn = "!git branch-name"

    po = "push origin ($(git branch-name))"

    # List the stashes
    sl = "stash list"

    # Show the contents of a numbered stash
    # Syntax:
    #   git st-show <int>
    st-show = "!f() { git stash show stash@{$1} -p; }; f"

    # Apply a stash, without deleting it from the list of stashes
    # Syntax:
    #   git st-copy <int>
    st-copy = "!f() { git stash apply stash@{$1}; }; f"

    # Unstage a file
    unstage = "reset HEAD"

    # Restore a file to the state it was in when checked out
    restore = "checkout --"

    # Compare local master repo to its upstream branch. If anything is returned, local branch has diverged from upstream.
    cm = "!f() { git fetch upstream master; git diff $(git branch-name) upstream/master --compact-summary; }; f"
    cml = "!f() { git fetch upstream master; git diff $(git branch-name) upstream/master; }; f"
```