我如何清理我的Github分叉,以便我可以提出干净的请求? [英] How do I clean up my Github fork so I can make clean pull requests?

查看:97
本文介绍了我如何清理我的Github分叉,以便我可以提出干净的请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Github上分发了一个仓库。我做了一些小改动,并向上游提交了pull请求,但是一路上我的fork已经变得如此受到破坏,我无法生成干净的pull请求;当我从一个有6个变更的分支开始提出pull请求时,Github想提交13个,其中7个已经存在上游(natch)。



我的问题似乎与只提取最新的提交,但是当我创建一个新的分支和樱桃挑选提交时,我仍然有额外的。我也使用重新绑定,但现在它甚至看起来像我的主人很混乱我无法生成上游。这显然是因为我不明白我需要 rebase而不是合并,很明显我犯了错误;我想要做的是弄清楚如何解开这个结,恢复到一个干净的状态,我可以有效地向前移动。



我有点想要吹离开我的岔路口,做出一个新的上游分支,但我也认为这很难。



在交代了我的Git罪孽之后,我该如何获得github赦免?

解决方案

第1步:取消上游更改

建议将上游回购添加为上游,如 Fork a Repo 页面:

  git pull --rebase upstream master 

- rebase 选项将您的第2步:(可选)将您的提交合并到1提交中

  git reset --soft upstream / master 

该命令将撤消所有提交,但不会更改文件。因此,您可以在一次提交中提交所有更改。

  git commit -a 

第3步:检查&测试你的改变

  gitk 

对于Mac OS X,您还可以使用 gitx

和for Windows也可以使用 TortoiseGit 的显示日志。



第4步:推送

git push 会引发错误,因为推送将更改目标存储库的历史记录。
如果您确信步骤3中显示的更改是正确的,请使用-f推送

  git push -f原产大师



其他信息 >
添加远程的命令是:

  git remote add upstream git://github.com/ [用户名] / [project] .git 

您也可以从直接网址获取:

  git pull --rebase git://github.com/ [username] / [project] .git 

但是在其他步骤中,您需要最新上游提交的散列,而不是上游/主。 >

I forked a repository on Github. I've made some minor changes and submitted pull requests to the upstream, but along the way my fork has become so mangled I'm unable to generate clean pull requests; when I start a pull request from a branch with six changes, Github wants to submit thirteen, with seven of them already existing upstream (natch).

My problem seems to be related to only pulling the latest commits, but when I create a new branch and cherry-pick commits I still have extras. I've futzed with rebasing as well, but now it looks like even my master is so messed up I can't generate a clean copy of upstream. This is apparently because I didn't understand that I needed to rebase instead of merging, so clearly I've made mistakes; what I'm trying to do is figure out how to unsnarl that knot and get back to a clean state where I can move forward usefully.

I kind of want to blow away my fork and make a new fork of the upstream, but I gather that, too, is difficult.

Having confessed my Git sins, how do I obtain github absolution?

解决方案

Step 1: Pull upstream changes
It's recommended to add the upstream repo as "upstream" as explained on the Fork a Repo page:

git pull --rebase upstream master

The --rebase option places your changes on top of the latest commit without merges.

Step 2: (Optional) Merge your commits into 1 commit

git reset --soft upstream/master

This command will "undo" all your commits, but won't change the files. So you can commit all your changes in a single commit.

git commit -a

Step 3: Check & test your changes

gitk

For Mac OS X you can also use gitx.
And for Windows you can also use TortoiseGit's "Show log".

Step 4: Push

git push will throw an error, because the push would change the target repository's history. If you're confident the changes shown in step3 are correct push with "-f"

git push -f origin master


Additional information
The command to add a remote is:

git remote add upstream git://github.com/[username]/[project].git

You can also also pull from a direct URL:

git pull --rebase  git://github.com/[username]/[project].git

But then you'll need the hash of the latest upstream commit instead of "upstream/master" in the other steps.

这篇关于我如何清理我的Github分叉,以便我可以提出干净的请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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