开发者

Pull all unfetched changes from git repository

I need to fetch everything from a few different, distinct repo开发者_如何学Csitories (all remote branches and all changes to those branches). I tried git pull --all but for some reason, I get the following message:

There are no candidates for merging among the refs that you just fetched.
Generally this means that you provided a wildcard refspec which had no
matches on the remote end.

So how would I go about ensuring that I get all the changes from a repository (without knowing what branches are on the other end, if possible)?

All help is appreciated and thanks in advance!


Generally speaking -- that's a really, really bad idea. Don't do that. "All remote branches" will often include work-in-progress code, abandoned code, conflicting implementations of the same feature, etc. Trying to merge them all into your local tree is a recipe for disaster.

Now, if you really wanted to do the very silly thing you suggested, you could do it something like thus:

git fetch remote_source
git merge $(git branch -r | grep remote_source)

Now, if all you really want to do is have a local copy of all remote changes, without trying to merge them into your tree, then you don't need to do a pull or merge at all; git fetch remote_source does it all for you. Sure, it doesn't create local branches mapped to the remotes -- but it does pull down the remote branches, and you can create local ones when and as you need them, with no further communication with the remote source required.


Given further problem description in the comments, it sounds like what you really want is to push all branches from your old remote to a new remote, not to merge them into a single tree. To do this, you'd probably want something like the following:

args=()
for remote_branch in $(git branch -r | grep OLD_REMOTE/); do
  branch_name=${remote_branch#*/}
  args+=( "${remote_branch}:${branch_name}" )
done
git push NEW_REMOTE "${args[@]}"


This seems like a very bad idea. But I guess you know what you are doing.

I use the following bash one liner though to do pushes to all remotes, which I've modified to do pulls instead.

for i in $(git remote); do git pull $i master; done;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜