Skip to content

Instantly share code, notes, and snippets.

@useafterfree
Last active January 7, 2020 02:52
Show Gist options
  • Select an option

  • Save useafterfree/aa1bda9c25e1cc0f80030385db8ff366 to your computer and use it in GitHub Desktop.

Select an option

Save useafterfree/aa1bda9c25e1cc0f80030385db8ff366 to your computer and use it in GitHub Desktop.
function deleteBranch()
{
BRANCH=$1
git push origin :$BRANCH
git branch -D $BRANCH
}
function renamebranch () {
OLD="$1"
NEW="$2"
git branch -m "$NEW"
git push origin :"$OLD" "$NEW"
}
function remoteresetter () {
COMMIT="$1"
BRANCH="$2"
git reset --hard "$COMMIT"
git push origin HEAD:$BRANCH --force
}
function listbranches ()
{
git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
}
function createbranch ()
{
git checkout -b $1
git push -u origin $1
}
function fetchall ()
{
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment