Skip to content

Instantly share code, notes, and snippets.

@ds82
Last active November 5, 2015 09:37
Show Gist options
  • Save ds82/6d565ad28988b5b25168 to your computer and use it in GitHub Desktop.
Save ds82/6d565ad28988b5b25168 to your computer and use it in GitHub Desktop.
some of my git aliases
branch-start = "!f() { git log $1 --reverse --ancestry-path $(git merge-base $1 HEAD)..HEAD --pretty=%H | head -n1; }; f"
branch-end = "!f() { git log $1 --ancestry-path $(git merge-base $1 HEAD)..HEAD --pretty=%H | head -n1; }; f"
merge-commit = "!f() { FROM=$(git branch-start $1 | cut -c1-6); TO=$(git branch-end $1 | cut -c1-6); git merge --ff-only $1; git commit --allow-empty -m \"merge ${1} ${FROM}..${TO}\"; }; f"
## csm = commit submodule with changes
csm = "!f() { git reset $1; HEAD=$(git diff --ignore-submodules=dirty --submodule=log $1 | head -n1 | sed -e 's/^Submodule //g' -e 's/:$//g'); TAIL=$(git diff --ignore-submodules=dirty --submodule=log $1 | tail -n +2 | sed -e 's/$/ /g'); git add -A $1 && git commit -m \"${HEAD}\" -m \"${TAIL}\"; }; f"
branch-name = "!git rev-parse --abbrev-ref HEAD"
last-branch-name = "!f() { echo $(git rev-parse --symbolic-full-name @{-1} | sed -e 's/refs\\/heads\\///' ); }; f"
lbn = "!git last-branch-name"
col = "!f() { git checkout $(git last-branch-name); }; f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment