Skip to content

Instantly share code, notes, and snippets.

@cybernetics
Forked from natescode/.gitconfig
Created July 13, 2022 03:38
Show Gist options
  • Save cybernetics/0fd08626be67498c6724ab53bc7f3ab2 to your computer and use it in GitHub Desktop.
Save cybernetics/0fd08626be67498c6724ab53bc7f3ab2 to your computer and use it in GitHub Desktop.

Revisions

  1. @natescode natescode revised this gist Jul 12, 2022. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion .gitconfig
    Original file line number Diff line number Diff line change
    @@ -48,6 +48,7 @@
    up = !git pull --rebase --prune $@ && git submodule update --init --recursive
    [push]
    default = current
    # automatically setup remote branch tracking without --set-upstream-branch
    autoSetupRemote = true
    [pull]
    [pull]
    default = current
  2. @natescode natescode revised this gist Jul 12, 2022. 1 changed file with 21 additions and 5 deletions.
    26 changes: 21 additions & 5 deletions .gitconfig
    Original file line number Diff line number Diff line change
    @@ -6,30 +6,46 @@
    co = checkout
    cob = checkout -b
    feat = "!f(){ git cob feature/${1}; };f"
    del = branch -D
    # Return the default branch for the repo i.e. master or main
    default = !git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'
    del = branch -D
    br-clean = "!f() { DEFAULT=$(git default); git branch --merged ${1-$DEFAULT} | grep -v " ${1-$DEFAULT}$" | xargs git branch -d; }; f"
    br = branch --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate
    save = !git add -A && git commit -m
    undo = reset HEAD~1 --mixed
    wipe = !git reset --hard
    done = !git push origin HEAD
    # Saves work in an unreachable commit, just in case, THEN WIPES it from existance
    wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
    done = "!f() { DEFAULT=$(git default); git checkout ${1-$DEFAULT} && git up && git br-clean ${1-$DEFAULT}; }; f"
    # Pretty log
    logs = !git log --pretty=format:\"%C(magenta)%h%Creset -%C(red)%d%Creset %s %C(dim green)(%cr) [%an]\" --abbrev-commit -30
    last = log -1 HEAD
    cm = commit -m
    ci = commit
    st = stash
    pop = stash pop
    apply = stash apply
    # get config info i.e. git conf user.name
    conf = config --global
    # quick work-in-progress commit
    wip = commit -am "WIP"
    # change commit message
    amend = commit -a --amend
    # Squash the last N commits. git squash 3, will reset the last 3 commits to the working directory then save them in a new commit
    squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f"
    # unstage file(s)
    unstage = restore --staged
    ## sync current feature branch with origin/develop
    syncod = !git fetch --all && git merge origin/develop
    ## sync current feature branch with given origin branch
    sync = "!f(){ git fetch --all && git merge origin/${1}; };f"
    # checkout develop branch
    dev = !git checkout develop
    master = !git checkout master
    # checkout the default branch i.e. master or main
    ma = "!f() { DEFAULT=$(git default); git checkout ${1-$DEFAULT}; }; f"
    master = !git checkout master
    main = !git checkout main
    rao = "!f(){ git remote add origin${1} && git push -u; };f"
    dev = !git checkout develop
    up = !git pull --rebase --prune $@ && git submodule update --init --recursive
    [push]
    default = current
    autoSetupRemote = true
  3. @natescode natescode revised this gist Jun 23, 2022. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions .gitconfig
    Original file line number Diff line number Diff line change
    @@ -31,4 +31,7 @@
    main = !git checkout main
    rao = "!f(){ git remote add origin${1} && git push -u; };f"
    [push]
    default = current
    autoSetupRemote = true
    [pull]
    default = current
  4. @natescode natescode revised this gist Jun 9, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .gitconfig
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    email = your_email
    name = your_username
    [alias]
    s = status~
    s = status
    co = checkout
    cob = checkout -b
    feat = "!f(){ git cob feature/${1}; };f"
  5. @natescode natescode revised this gist Jun 9, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions .gitconfig
    Original file line number Diff line number Diff line change
    @@ -30,3 +30,5 @@
    master = !git checkout master
    main = !git checkout main
    rao = "!f(){ git remote add origin${1} && git push -u; };f"
    [push]
    autoSetupRemote = true
  6. @natescode natescode revised this gist May 26, 2022. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions .gitconfig
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,10 @@
    email = your_email
    name = your_username
    [alias]
    s = status
    s = status~
    co = checkout
    cob = checkout -b
    feat = "!f(){ git cob feature/${1}; };f"
    del = branch -D
    br = branch --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate
    save = !git add -A && git commit -m
    @@ -23,8 +24,9 @@
    amend = commit -a --amend
    squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f"
    unstage = restore --staged
    synco = !git fetch --all && git merge
    syncod = !git fetch --all && git merge origin/develop
    sync = "!f(){ git fetch --all && git merge origin/${1}; };f"
    dev = !git checkout develop
    master = !git checkout master
    main = !git checkout main
    rao = "!f(){ git remote add origin${1} && git push -u; };f"
  7. @natescode natescode revised this gist Apr 15, 2022. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions .gitconfig
    Original file line number Diff line number Diff line change
    @@ -3,14 +3,14 @@
    name = your_username
    [alias]
    s = status
    co = checkout
    cob = checkout -b
    del = branch -D
    br = branch --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate
    save = !git add -A && git commit -m
    undo = reset HEAD~1 --mixed
    wipe = !git reset --hard
    done = !git push origin HEAD
    co = checkout
    cob = checkout -b
    del = branch -D
    br = branch --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate
    save = !git add -A && git commit -m
    undo = reset HEAD~1 --mixed
    wipe = !git reset --hard
    done = !git push origin HEAD
    logs = !git log --pretty=format:\"%C(magenta)%h%Creset -%C(red)%d%Creset %s %C(dim green)(%cr) [%an]\" --abbrev-commit -30
    last = log -1 HEAD
    cm = commit -m
  8. @natescode natescode revised this gist Apr 15, 2022. No changes.
  9. @natescode natescode revised this gist Apr 15, 2022. No changes.
  10. @natescode natescode revised this gist Apr 15, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .gitconfig
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@
    amend = commit -a --amend
    squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f"
    unstage = restore --staged
    synco = !git fetch --all && git merge
    synco = !git fetch --all && git merge
    sync = "!f(){ git fetch --all && git merge origin/${1}; };f"
    dev = !git checkout develop
    master = !git checkout master
  11. @natescode natescode created this gist Apr 15, 2022.
    30 changes: 30 additions & 0 deletions .gitconfig
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    [user]
    email = your_email
    name = your_username
    [alias]
    s = status
    co = checkout
    cob = checkout -b
    del = branch -D
    br = branch --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate
    save = !git add -A && git commit -m
    undo = reset HEAD~1 --mixed
    wipe = !git reset --hard
    done = !git push origin HEAD
    logs = !git log --pretty=format:\"%C(magenta)%h%Creset -%C(red)%d%Creset %s %C(dim green)(%cr) [%an]\" --abbrev-commit -30
    last = log -1 HEAD
    cm = commit -m
    ci = commit
    st = stash
    pop = stash pop
    apply = stash apply
    conf = config --global
    wip = commit -am "WIP"
    amend = commit -a --amend
    squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f"
    unstage = restore --staged
    synco = !git fetch --all && git merge
    sync = "!f(){ git fetch --all && git merge origin/${1}; };f"
    dev = !git checkout develop
    master = !git checkout master
    main = !git checkout main