因爲它通常與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
你的意思是,你想創建新的根提交與其他提交相同的內容? – PetSerAl
問題需要澄清。製作示例圖可以提供很多幫助。 – LopSae