git - 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?
解决方案
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
推荐阅读
- google-cloud-run - 如何将两个 Cloud Run 应用程序放在一个域下以避免 CORS
- openlayers - 当地图不是全尺寸时如何适应 openlayers 地图?
- android - 当我在手机上启动 ionic 应用程序时,我在终端上看不到日志
- scala - 在 Spark 中比较两个相同结构的数据帧
- git - 如何在没有 git 或 git 存储库的情况下将 git 冲突文件拆分为两个?
- html - 如何在电子商务网站的缩略图上复制此刻度线?具体来说,右上角的勾
- android - 如何检查 woocommerce rest-API 优惠券代码是否有效?
- c# - 我可以在这里使用什么来代替(开关)?
- excel - 使用 Excel VBA 复制列中的范围
- django - Django DRY 模型