2

Here is my situation - say I have two projects 'Proj0' and 'Proj1' and three distinct git repositories 'repo0', 'repo1', and 'repo2' on which both of these projects rely. For whatever historical and contractual reasons, these two projects depend on different versions (branches) of these three repos. So, for Proj0, repo0 needs to be on master, repo1 needs to be on dev, and repo2 needs to be on release. While for Proj1, repo0 needs to be on bugFix0, repo 2 needs to be on dev, and repo3 needs to be on dev. Summary:

Proj0:
  repo0: master
  repo1: dev
  repo2: release

Proj1:
  repo0: bugFix0
  repo1: dev
  repo2: dev

At some point in the future, repo0:bugFix0 will be approved and merged into master and so all developers of Proj1 will need to switch to master once that fix is approved.

My question is, is there a way in git to setup branch aliases such that I can point a globally shared aliased name to specific branches? This way, I can specify that all developers of Proj0 checkout a branch called branch0 and all developers of Proj1 checkout a branch called branch1 for all repos. For each repo, the alias would just point to the current actual branch that the project is tracking, e.g. repo0:branch0->master, repo0:branch1->bugfix0, repo1:branch0->dev, repo1:branch1->dev, repo2:branch0->release, and repo2:branch1->dev. Thus, the above table would simply look like the following:

Proj0:
  repo0: branch0 (master)
  repo1: branch0 (dev)
  repo2: branch0 (release)

Proj1:
  repo0: branch1 (bugfix0)
  repo1: branch1 (dev)
  repo2: branch1 (dev)

Then, when the bugfix0 is approved and merged into master, the repo0:branch1 alias would just have to be changed to point to master and the table would look like this:

Proj0:
  repo0: branch0 (master)
  repo1: branch0 (dev)
  repo2: branch0 (release)

Proj1:
  repo0: branch1 (master)
  repo1: branch1 (dev)
  repo2: branch1 (dev)

Note: I've looked at git symbolic-ref and it's not quite what I want - I don't thing, but might be close, or maybe I'm using it wrong. The key here is that ongoing development on repo1:dev should be tracked by repo1:branch0 globally. Really I just want multiple names for branches (i.e. branch aliases).

Thanks in advance for any help!

colby
  • 49
  • 2
  • Git doesn't do that; symbolic-ref is about as close as it gets. As you saw, it's pretty close, but `git branch` gives you the name of the underlying branch, and every time you use the indirect name, git always operates on the "real branch" instead (including if you ask to delete it!). – torek Sep 29 '14 at 18:25
  • yea - that's more or less what I've found to be the case. Bummer too, seems like it'd be a useful tool in general. I'd be open to other suggestions on how other folks are solving this problem. I may resort to just making a script with a simple repo-branch mapping that auto checks out the right branches for each repo depending on your project or something like that. – colby Sep 30 '14 at 12:42
  • Possible duplicate of [git - branch alias?](https://stackoverflow.com/questions/14365946/git-branch-alias) – Rémi.B Sep 13 '18 at 08:46

0 Answers0