Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Track multiple remote branches

Tags:

git

git-remote

So let's say there are three developers: Alice, Bob, and Cecil. They decide to use Git without a central repo. They all set up remotes to each other, so that:

  • Alice has remotes/bob/master
  • Alice has remotes/cecil/master
  • Bob has remotes/alice/master
  • Bob has remotes/cecil/master
  • Cecil has remotes/alice/master
  • Cecil has remotes/bob/master

And now, Alice wants her local master branch to track both remote master branches. Is that even possible in Git? If not, what workflow do you guys use to work around this?

like image 588
Jasiu Avatar asked Dec 27 '10 13:12

Jasiu


People also ask

How do I get a list of branches on a remote?

To view your remote branches, simply pass the -r flag to the git branch command. You can inspect remote branches with the usual git checkout and git log commands. If you approve the changes a remote branch contains, you can merge it into a local branch with a normal git merge .

How do I track a remote branch?

When you're publishing a local branch. You can tell Git to track the newly created remote branch simply by using the -u flag with "git push".

How can I tell if a remote branch is tracked?

There is a command that gives you about all tracking branches. And to know about the pull and push configuration per branch you can use the command git remote show origin. and you can use -sb option for seeing the upstream. Hope this information will help you to find which branch is tracking.

What does track remote branch mean in Visual Studio?

Tracking a remote branch means you want to automatically merge changes from the remote branch you're tracking into your local branch. The default behavior of git push pushes changes into a configured upstream only when the names of the local and remote are the same.


1 Answers

How to track more than one remote with a given branch using Git?

In short, "can't be done unless you write a custom script/program/alias".

I suggest that they either agree on a common central branch that holds the development tree, or that they send each other pull requests instead of asking each developer to track every other developer.

like image 71
Arafangion Avatar answered Sep 21 '22 15:09

Arafangion