admin管理员组文章数量:1410717
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:eclipse-rcptt/.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:eclipse-rcptt/.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?
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:eclipse-rcptt/.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:eclipse-rcptt/.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
Reset to default 2Your 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/*"
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.
本文标签: git fetchA simple command to configure git pullStack Overflow
版权声明:本文标题:git fetch - A simple command to configure `git pull` - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745009921a2637486.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论