首页 > 解决方案 > IntelliJ Git Multiple Local Repositories, adding a new Repo ruins the 'Common Local Branches' paradigm. How to recover?

问题描述

My company has many (roughly 10) git repositories and I use IntelliJ in the mode where branch operations are executed on all repositories. It wasn't my decision to have this many repos and whether this is a good idea is not the subject of this question, thanks for understanding.

Usually intelliJ displays 'common local branches', those experienced with this feature will know that "common" does not mean "frequently used" but rather it means "common to all repositories".

Now we have added one more repository, call it 'newshared'. Because this repository is newer, my local branches do not exist in 'newshared' and now the functionality that drives the 'common local branches' feature no longer lists any of the branches from before.

Is there any way to recover from this scenario? I would be fine with creating branch pointers in the new local repository, but I have a few dozen branches that I would have to do this for. Is there a way to do this automatically without my going into 'newshared' and adding tags for dozens of branches?

标签: gitintellij-idea

解决方案


You are right, to restore the parallel control you need all repos to be on the same branch, and for the branches to be listed in Common Local Branches, they should exist in all repos.

Unfortunately, there is no way to automatically sync branches across repos from the UI, so this has to be done manually. Luckily, creating a branch in git is very lightweight so it is pretty easy to create all the necessary branches in the new repo with e.g. xargs command. Something like git branch | xargs -L 1 git --git-dir=../newshared/.git branch from one of the existing neighbour repositories


推荐阅读