Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Can I configure git such that

git pull

will always pull remote:master into my local master branch, regardless of which branch I'm currently on?

share|improve this question
    
Stack Overflow might be a better place for Git questions. –  grawity Sep 27 '13 at 13:37

1 Answer 1

up vote 2 down vote accepted

No. git pull cannot do that.

The pull command is basically a shortcut for fetch + merge. The first step is to fetch all remote branches into local "remote-tracking" ones; the second step is to merge the appropriate remote-tracking branch into the current branch. Since a proper merge requires a working tree, Git does not allow merging into anything else except the currently checked out branch.

You can, however, fast-forward branches. If you don't have any local commits in master and all merges are going to be fast-forwards, then you can make an alias for:

git fetch && git push . origin/master:master

This fetches all branches, then pushes the new commits from origin/master into master in the same repository (here . means "this repository"). The same could be done using various other commands, but pushing is a convenient way to ensure that only fast-forwards will happen and no commits will be lost.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.