[英]Git push all parent commits to the remote (ie rewrite remote history)
A bit of context: I recently migrated from CVS to Git using cvsimport. 有一点背景:最近我使用cvsimport从CVS迁移到Git。 There is now a common (bare) repository, managed by gitolite, where people push their local changes.
现在有一个通用的(裸露的)存储库,由甘露石管理,人们可以在那里进行本地更改。 I then discovered that many tags from the old CVS history were not perfectly imported.
然后,我发现旧CVS历史中的许多标签没有被完美地导入。 I could fix that by re-doing the migration from CVS using cvs2git (locally), and grafted the branches' heads of my first repo onto the new tree given by cvs2git (still locally).
我可以通过使用cvs2git从本地重新执行从CVS的迁移来解决此问题,然后将我的第一个存储库的分支头移植到cvs2git提供的新树上(仍在本地)。 I now have a complete tree with a nicer history than before, where the heads of all the branches have the same hash as what is currently on the remote (I used grafts and filter-branch, as in this answer: https://stackoverflow.com/a/2428339/1005470 )
现在,我有一棵历史比以前更好的完整树,其中所有分支的头都具有与远程服务器上当前哈希值相同的哈希值(我使用了嫁接和过滤器分支,如以下答案所示: https:// stackoverflow .com / a / 2428339/1005470 )
What I would now like to do is to push those changes to the remote. 我现在想做的就是将这些更改推送到遥控器上。 Of course,
git push
returns that everything is up-to-date: I don't know how to push a re-written history . 当然,
git push
返回所有内容都是最新的:我不知道如何推送重写的历史记录 。 Because the refs match, git push -f
also returns that everything is up-to-date. 因为refs匹配,所以
git push -f
还返回一切都是最新的。
Moreover, I would of course like that other developers barely notice that something has changed. 而且,我当然希望其他开发人员几乎没有注意到某些变化。 They should just see an updated history next time they pull (I'm also OK if they have to re-clone).
下次拉动它们时,他们应该只会看到更新的历史记录(如果必须重新克隆,我也可以)。 I am assuming that they have not based any work on commits prior to the branches' heads (I am aware that it would otherwise be a big mess).
我假设他们在分支机构负责人之前没有基于提交的任何工作(我知道否则会很麻烦)。
Edit: to clarify, here is (an extract of) the output of git rev-list HEAD
on both repositories. 编辑:澄清一下,这是两个存储库上
git rev-list HEAD
的输出(摘录)。 The commit in bold is the point where I did the graft. 以粗体显示的提交是我进行嫁接的地方。 I would like to overwrite everything below that point in the remote by what I have in the local repository.
我想用本地存储库中的内容覆盖远程位置以下的所有内容。
Local repo :
本地仓库 :
fff881c238fff8b0057be8dab494ec5a6aa181d9fff881c238fff8b0057be8dab494ec5a6aa181d9
ac513b5596cca48dd885a969fdcc4a2b49e507d0ac513b5596cca48dd885a969fdcc4a2b49e507d0
1b199d8e4ac29e4bd39ff96059031cf9b13906091b199d8e4ac29e4bd39ff96059031cf9b1390609
427837c98a14f28bc2e5d91fcf89e954b3bb3e77427837c98a14f28bc2e5d91fcf89e954b3bb3e77
0d9e58cc4f6a0107c718c689e24353d4ce59ab8c0d9e58cc4f6a0107c718c689e24353d4ce59ab8c
........
Remote repo :
远程仓库 :
6ad634da6e5acda43e6cf0919e8f4994c08ac8626ad634da6e5acda43e6cf0919e8f4994c08ac862
bd32b7c9b0ae4faea51720b98586f89972b52e58bd32b7c9b0ae4faea51720b98586f89972b52e58
3778ce4ff85f269e2287d57c7aec3ecefabc135a3778ce4ff85f269e2287d57c7aec3ecefabc135a
d3c343f3498d1d82b680be2ffc2c5e05c14a3d4cd3c343f3498d1d82b680be2ffc2c5e05c14a3d4c
a5d200b99f31a005cc8312d0a23a79d4014a2156a5d200b99f31a005cc8312d0a23a79d4014a2156
8b90afbbb06bea062d26b520c42c068ef96e5db78b90afbbb06bea062d26b520c42c068ef96e5db7
fff881c238fff8b0057be8dab494ec5a6aa181d9fff881c238fff8b0057be8dab494ec5a6aa181d9
19cf091efb12413027941ac893ea8d503fea415e19cf091efb12413027941ac893ea8d503fea415e
efbed577d5986beef45ba0f9a2560f4b1ca120fcefbed577d5986beef45ba0f9a2560f4b1ca120fc
bbec686e3389abe0679672a3d71c236b98ffc111bbec686e3389abe0679672a3d71c236b98ffc111
5b56665e48b3af51a25d0c9d2342d04e730aaa165b56665e48b3af51a25d0c9d2342d04e730aaa16
2ce095b0ed92f22baf74e728bda07bfded5a4e7b2ce095b0ed92f22baf74e728bda07bfded5a4e7b
......
It looks like your local branches are not set up to track the remote branches. 看来您的本地分支未设置为跟踪远程分支。
You will need to either set remote tracking in your branches (check the --set-upstream
option for the branch
command) and then do a bare git push
; 您将需要在分支中设置远程跟踪(检查
branch
命令的--set-upstream
选项),然后执行裸git push
; or push each branch individually, specifying the branch names in the push command: git push --set-upstream <remote> <remote-branch-name>
for each branch, while having that branch checked out. 或单独推送每个分支,在push命令中指定分支名称:
git push --set-upstream <remote> <remote-branch-name>
每个分支,同时将该分支检出。
I hope this helps. 我希望这有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.