Git aliases to combine fetch in the background and checkout/merge/rebase

I decided to write down few useful Git aliases I’m using every day.

git config --global alias.fetch-master "!git fetch -p && git fetch origin master:master"

git config --global alias.fetch-checkout "!git fetch-master && git rev-parse --abbrev-ref HEAD > .git/BRANCH && git checkout master && git branch -D `cat .git/BRANCH` && rm .git/BRANCH"

git config --global alias.fetch-merge "!git fetch-master && git merge master"

git config --global alias.fetch-rebase "!git fetch-master && git rebase master"

Or how it looks in .gitconfig:

[alias]
  fetch-master = !git fetch -p && git fetch origin master:master
  fetch-checkout = !git fetch-master && git rev-parse --abbrev-ref HEAD > .git/BRANCH && git checkout master && git branch -D `cat .git/BRANCH` && rm .git/BRANCH
  fetch-merge = !git fetch-master && git merge master
  fetch-rebase = !git fetch-master && git rebase master
This entry was posted in Programming and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.