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-checkout "!git fetch -p && git fetch origin master:master && git checkout master"

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

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

Or how it looks in config:

[alias]
  fetch-checkout = !git fetch -p && git fetch origin master:master && git checkout master
  fetch-merge = !git fetch -p && git fetch origin master:master && git merge master
  fetch-rebase = !git fetch -p && git fetch origin master:master && git rebase master

Updated version of checkout which deletes current branch after switching to master:

[alias]
  fetch-checkout = !git fetch -p && git fetch origin master:master && git rev-parse --abbrev-ref HEAD > .git/BRANCH && git merge master && git branch -D `cat .git/BRANCH` && rm .git/BRANCH
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.