2

My remote repository has hundreds of branches, so fetch is configured conservatively:

 % git config --get-all remote.origin.fetch +refs/heads/master:refs/remotes/origin/master refs/heads/release/2.5:refs/remotes/origin/release/2.5 

When I'm trying to work with a new remote branch, argumentless pull does not work:

 % git status On branch platform_4.33 nothing to commit, working tree clean % git pull --set-upstream origin platform_4.33 From github.com:eclipse-rcptt/org.eclipse.rcptt * branch platform_4.33 -> FETCH_HEAD Already up to date. % git pull Your configuration specifies to merge with the ref 'refs/heads/platform_4.33' from the remote, but no such ref was fetched. 

I can complete the configuration manually:

 % git config --add remote.origin.fetch +refs/heads/platform_4.33:refs/remotes/origin/platform_4.33 % git pull From github.com:eclipse-rcptt/org.eclipse.rcptt * [new branch] platform_4.33 -> origin/platform_4.33 Already up to date. 

git config is cumbersome, error prone and requires manual pruning once branch is deleted. I do not care about "Remote Tracking Branches", remote.origin.fetch would be empty if it did not break git pull.

How can I configure git pull (without arguments) with fewer or with simpler commands?

2 Answers 2

2

Your Git fetch configuration only pulls specific branches, so new ones aren’t fetched automatically.

To fix this, run git fetch --all before checking out a new branch git checkout --track origin/platform_4.33

or

change remote.origin.fetch to get all branches git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"

Sign up to request clarification or add additional context in comments.

2 Comments

git checkout --track origin/platform_4.33 fatal: cannot set up tracking information; starting point 'origin/platform_4.33' is not a branch
refs/heads/* would fetch branches I do not need
2

Workaround

git pull does not need remote.origin.fetch setting. It can be removed.

git config --unset-all remote.origin.fetch git pull --set-upstream origin platform_4.33 git pull # Works as expected 

With this configuration no extra branches are fetched and git pull properly handles "--set-upstream".

remote.origin.fetch setting is needed for git maintenance run --task prefetch and probably other activities, but I do not use prefetch or remote tracking branches, so this approach works for me.

I still have no idea why additive configuration is breaking things.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.