Git仓库提交
问题描述:
我有一个Git仓库,其具有n个承诺,我想创造一些特别米的新仓库提交,Git仓库提交
例, 资源库中有10个提交,并从第4犯我要创建一个新的库B的独立A的
我试过许多东西,但他们没有工作像 混帐克隆,然后在新目录中的git结算和多堆栈溢出的答案,
How do I create a new git repository from a folder in an existing git repository?
how to create a new git repository from an existing one
但是无法在提交方面执行它。任何人都可以请帮忙。
感谢
答
克隆回购A. 打开遥控“出身”,如果你想它的独立。 然后(学习如何和)使用git rebase -i
来选择提交保留,删除或挤压。 如果你只有10个提交,并且你想删除的提交没有后来提交的发生,它应该很好...
答
因为它通常与git
,有很多方法皮猫:)
上述答案另一种方法是添加一个空仓库为远程和推提交使用git push other_remote commit:refs/heads/master
这里有一个演示:
# Set up the parent repo
$ git init repo1
Initialized empty Git repository in /tmp/repo1/.git/
$ cd repo1
$ seq 10 | xargs --replace git commit -m 'commit {}' --allow-empty
[master (root-commit) 7444793] commit 1
[master 6b12c35] commit 2
[master 3743f03] commit 3
[master b4221a7] commit 4
[master f7e1009] commit 5
[master 4c8e4e9] commit 6
[master 6618f10] commit 7
[master a1c1b26] commit 8
[master 802bed2] commit 9
[master 13734f2] commit 10
# Set up the new repo
git init ../repo2
# Allow pushing to the master branch
git -C ../repo2 config receive.denyCurrentBranch ignore
# Add the other repo as a remote
git remote add other_remote ../repo2
# Push the commit 5-back to repo2's master branch
# Note you can use anything that resolves to a refish like thing (a branch, a commit, a tag, etc.)
git push other_remote HEAD^^^^^:refs/heads/master
# Show our handywork
$ cd ../repo2
$ git log --oneline
f7e1009 commit 5
b4221a7 commit 4
3743f03 commit 3
6b12c35 commit 2
7444793 commit 1
答
比方说,提交历史Ø在回购A中的f master
是A-B-C-D-E
。目标是创建一个分支指向C
的回购B.
git init RepoB
cd RepoB
git fetch <path_of_RepoA> master
git checkout -b master C
你的意思是,你想创建新的根提交与其他提交相同的内容? – PetSerAl
问题需要澄清。制作示例图可以提供很多帮助。 – LopSae