我想将一个git存储库分成两个,例如"项目"和"项目/工具"。目前有两个分支("主要"用于项目,"工具和#34;用于项目/工具)反映了这一发展(两者的具体变化):
repo(s) branch(es)
------------- -------------
now project master, tools
| |
new project master |
tools master <--+
我可以删除/移动各自分支机构中的相应文件(例如删除&#34;工具&#34; dir in&#34; master&#34;分支和除#34;工具&#34;之外的所有内容&#34; tools&#34; branch)然后以某种方式从这两个分支创建独立的存储库(复制,删除其他分支,重命名分支和存储库)?
是否有直接自动执行此操作的命令(git-subtree split或git filter-branch)?
答案 0 :(得分:1)
如果每个分支只触及您关注的文件,一种简单的方法可能就是使用git clone --single-branch --branch [master/tools]
--[no-]single-branch
Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary
branch remote's HEAD points at. When creating a shallow clone with the --depth option, this is the default, unless
--no-single-branch is given to fetch the histories near the tips of all branches. Further fetches into the resulting
repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If
the HEAD at the remote did not point at any branch when --single-branch clone was made, no remote-tracking branch is
created.