git - 设置一个提交的父母没有rebase [英] git - setting a commit's parent without rebase

查看:136
本文介绍了git - 设置一个提交的父母没有rebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 git-svn 来创建一个SVN仓库的git镜像。 SVN内部的结构有点不符合标准,所以git创建了一个没有与 master 分支共同提交的分支。

I used git-svn to create a git mirror of an SVN repository. The structure inside the SVN was a little off-standard, so git created a branch that has no common commit with the master branch.

      A---B---C topic

D---E---F---G master

我知道commit A 是基于commit E ,我非常肯定我已经修复了导致git无法识别该事实的问题(使用 filter-branch ) 。我想要做的是将主题重新附加到 master 分支中,设置 E 作为 A 的父项:

I know that commit A is based off commit E and I'm pretty positive that I've fixed the issues causing git not to recognize that fact (using filter-branch). What I want to do is re-attach topic to the master branch, setting E as the parent of A:

      A---B---C topic
     /
D---E---F---G master

git-rebase 对我来说似乎不起作用,因为commit A 列出了在 master 中已经存在的大量文件的创建,导致大量冲突。

从我的理解的git只需将 E 设置为 A 的父项就足以解决所有问题。

这可能吗?如果是这样,我该怎么做?

git-rebase doesn't seem to work for me because the diff for commit A lists the creation of a whole lot of files that already exist in master, resulting in a huge number of conflicts.
From my understanding of git just setting E as the parent of A should be enough to solve all problems.
Is this possible? If it is, how can I do it?

推荐答案

查看移植文件(移植文件可以在的.git /信息/移植物)。格式非常简单:

Have a look at grafts (the graft file can be found in .git/info/grafts). The format is pretty simple:

<commit sha1> <parent1 sha1> <parent2 sha1> … <parentN sha1>

这使得git相信一个提交具有与实际不同的父项。使用过滤分支来移植永久(所以移植文件可以被删除):

This makes git believe that a commit has different parents than it actually has. Use filter-branch to make grafts permanent (so the grafts file can be removed):

git filter-branch --tag-name-filter cat -- --all

请注意,改写历史记录因此不应该在共享回购站上使用!

Note that this rewrites history of the repository, so should not be used on shared repos!

如果您只想重写提交的历史记录例如,使用以下命令:

If you only want to rewrite the history of the commits that are being grafted onto the master branch, for example, use this command:

git filter-branch --tag-name-filter cat -- master..

这篇关于git - 设置一个提交的父母没有rebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆