How do I configure Git to automatically pull from current branch when using "git pull"?


With our current setup you always have to enter the branch name (ie: git pull origin feature-branch” when doing a pull. I’ve already made the mistake of pulling from one branch into another, accidentally merging two branches with two very different releases. I’d like to avoid this by configuring Git so that simply typing git pull will pull the current branch you’re in.

How do I do this?


You can create a tracking branch. From the Git Book (

When you clone a repository, it generally automatically creates a
master branch that tracks origin/master. That’s why git push and
git pull work out of the box with no other arguments. However, you
can set up other tracking branches if you wish — ones that don’t track
branches on origin and don’t track the master branch. The simple
case is the example you just saw, running
git checkout -b [branch] [remotename]/[branch]. If you have Git
version 1.6.2 or later, you can also use the --track shorthand:

$ git checkout --track origin/serverfix
Branch serverfix set up to track remote branch refs/remotes/origin/serverfix.
Switched to a new branch "serverfix"

Answered By – Karthik Ramachandran

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published