[英]Pull request from a different repository
I didn't know how forks and clones work.我不知道分叉和克隆是如何工作的。 So in order to copy someone else's repo and work on it, I downloaded the repo's files (using no source control), created my own new repository, and then committed those files to it.
因此,为了复制别人的存储库并对其进行处理,我下载了存储库的文件(不使用源代码控制),创建了我自己的新存储库,然后将这些文件提交给它。
I want to pull request my repo's master to the original repo, but I can't because it's not a fork.我想请求我的回购协议的主人到原始回购协议,但我不能,因为它不是叉子。 Furthermore - git doesn't even know that they originate from the same source, and hence if I checkout the original repo, open a new fork, copy-paste all the files from my private repo to the new fork, and pull request it back in, it will show it as a single giant commit, and I'll lose all of the commit and comment history on the old repo, which will be terrible.
此外 - git 甚至不知道它们来自同一来源,因此如果我检查原始回购,打开一个新的分叉,将所有文件从我的私人回购复制粘贴到新的分叉,然后拉回请求in,它将显示为单个巨大的提交,我将丢失旧回购协议中的所有提交和评论历史,这将是可怕的。
Is there a way for me to pull request my changes back into the original repo without losing all the history of my copied repo?有没有办法在不丢失我复制的回购的所有历史记录的情况下,将我的更改请求拉回原始回购?
git status
and git diff
and commit them.git status
和git diff
查看更改并提交它们。unfortunately there is no way to merge two branches that dont have a common ancestor commit.不幸的是,没有办法合并两个没有共同祖先提交的分支。 even if the files are the same.
即使文件相同。
A very hacky workaround however goes as follows:然而,一个非常hacky的解决方法如下:
Its a laborious process, and you could probably create a tool to do it, but if its not a lot of commits, or you dont mind combining a few commits into one.这是一个费力的过程,您可能可以创建一个工具来完成它,但是如果提交不是很多,或者您不介意将几个提交合并为一个。 (to do this, in step 3, just skip a couple of commits, the code from previous commits will still be there)
(要做到这一点,在第 3 步中,只需跳过几次提交,之前提交的代码仍然存在)
You need first to connect the old repository OLD (containing proper git history) to the new one NEW (disconnected but containing modifications) by:您首先需要通过以下方式将旧存储库 OLD(包含正确的 git 历史记录)连接到新存储库(断开连接但包含修改):
git checkout $(git rev-list --max-parents=0 HEAD | tail -n 1)
git checkout $(git rev-list --max-parents=0 HEAD | tail -n 1)
rsync -avrI. /path/to/NEW
rsync -avrI. /path/to/NEW
rsync -avrI. /path/to/NEW
git checkout main && git format-patch -1 $(git rev-list --max-parents=0 HEAD | sed 'x;$!d')
git checkout main && git format-patch -1 $(git rev-list --max-parents=0 HEAD | sed 'x;$!d')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.