Skip to content

Instantly share code, notes, and snippets.

@oakfang
Created April 28, 2015 12:25
Show Gist options
  • Save oakfang/af59c0c82604db22c590 to your computer and use it in GitHub Desktop.
Save oakfang/af59c0c82604db22c590 to your computer and use it in GitHub Desktop.
Git commands to make life easier
# Show all commits of current branch since its beginning
# Add flags as though it were git log
git log $(git parent)..HEAD $*
# Show current branch name
git rev-parse --abbrev-ref HEAD
# Show all branches prettily according to git flow
git branch --list --no-color $1 | tr -d '* ' | perl -pe 's/feature\//\e[0;32mFeature: \e[0m/' | perl -pe 's/bug\//\e[0;31mBug: \e[0m/' | perl -pe 's/release\//\e[0;36mRelease: \e[0m/' | perl -pe 's/(develop|master)/\e[46m\1\e[0m/'
# Rebase side branch to another side branch (such as a release branch)
# If you use this, you're probably patching something :(
git rebase --onto $1 $(git parent) $(git current)
# Show persumed parent branch of current branch
branch=`git current`
git show-branch | ack '\*' | ack -v "$branch" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment