Last active
December 24, 2016 05:09
-
-
Save robmiller/5686166 to your computer and use it in GitHub Desktop.
A few useful commands for working with branches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git branch-name: prints the name of the branch in a safe/scriptable/non-porcelain way | |
# git publish: publishes the current branch on the remote "origin", using the same name as the current branch | |
# git unpublish: deletes the remote branch with the same name as the current one (potentially destructive) | |
# git recreate: given a branch name, recreates the branch with that name from the latest master. Deletes both the local and remote copy of the branch first. Very destructive, use with caution | |
branch-name = "!git rev-parse --abbrev-ref HEAD" | |
publish = "!git push -u origin $(git branch-name)" | |
unpublish = "!git push origin :$(git branch-name)" | |
recreate = "!f() { [[ -n $@ ]] && git checkout \"$@\" && git unpublish && git checkout master && git branch -D \"$@\" && git checkout -b \"$@\" && git publish; }; f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment