简体   繁体   English

进行rebase将重播master分支提交到我的Pull Request中

[英]Doing rebase adds replays master branch commits into my Pull Request

I have a pull request here , and when I did "git rebase", it added commits that I didn't author into the pull request. 我在这里有一个拉取请求,当我执行“ git rebase”时,它添加了我未编写的提交到拉取请求中。 The remote branch I'm merging is ahead of all of those commits so I don't understand why they are getting into PR. 我要合并的远程分支位于所有这些提交之前,因此我不明白他们为什么进入PR。 Any idea how to undo this, or how to prevent this in the future? 知道如何撤消此操作,或将来如何防止此操作?

Here's what I did 这就是我所做的

# Checkout local branch and apply changes
mkdir /home/yaroslavvb/tfimmediate_fresh
cd /home/yaroslavvb/tfimmediate_fresh
git clone https://github.com/yaroslavvb/tensorflow.git
cd tensorflow
git checkout tfimmediate_fresh
# do my modifications
git commit -m "Changes"

# Rebase against main branch
git remote add tfmain https://github.com/tensorflow/tensorflow.git
git fetch tfmain
git rebase tfmain/master

# fix conflicts
git add tensorflow/contrib/__init__.py
git rebase --continue
git pull
# fix conflicts again
git add tensorflow/contrib/__init__.py
git commit -m "Fix merge conflicts"
git push
git push -f

After this, my pull request contains changes in master branch that I didn't author 之后,我的拉取请求包含我未编写的master分支中的更改

While rebasing, you did a git pull after your git rebase --continue . 在重新设置基准时,您在git rebase --continue之后进行了git pull

This will merge new commits from the origin/master branch with your local branch, and so includes the merged commits in your pull request. 这会将来自origin / master分支的新提交与您的本地分支合并,因此将合并的提交包括在请求请求中。

After rebasing you should just push the changes to the branch you will use for the Pull Request. 重新设定基准后,您只需将更改推送到将用于“拉取请求”的分支即可。

Welcome to my life every time I rebase. 欢迎我每次改建生活。 Hopefully we can both avoid this in the future by listening to Olivier and not pulling. 希望我们将来都可以通过听Olivier而不是拉扯来避免这种情况。 🤞 🤞

But, okay, you already did this and now you're in a mess. 但是,好的,您已经这样做了,现在您一团糟。 What do? 做什么? I used to just create a new branch, copy over my changes, and make a new PR, but we don't have to live life this way. 我以前只是创建一个新分支,复制所做的更改,然后进行新的PR,但我们不必这样生活。 You can delete the commits. 您可以删除提交。

git log will give you a list of commits. git log将为您提供提交列表。 You can then grab the SHAs and remove individual commits using this: 然后,您可以使用以下方法获取SHA并删除单个提交:

git rebase -p --onto 4196caae8735bb983a2a0bace6f72b0820a755c1^ 4196caae8735bb983a2a0bace6f72b0820a755c1 (Note: if you're using zsh, you'll need to backwack the ˆ .) git rebase -p --onto 4196caae8735bb983a2a0bace6f72b0820a755c1^ 4196caae8735bb983a2a0bace6f72b0820a755c1 (注:如果您使用的zsh,你需要backwack的ˆ

Once you've killed the commit(s), you can't simply git push , because the remote branch still has those extra commits. 一旦杀死了提交,就不能简单地git push ,因为远程分支仍然具有这些额外的提交。 Instead, do the potentially-dangerous git push origin -f to force the remote branch to match yours (rather than the other way around). 相反,执行潜在危险的git push origin -f强制远程分支与您的分支匹配(而不是相反)。

Disclaimer: I don't know what I'm doing. 免责声明:我不知道我在做什么。 But after a few attempts attempts, I got to the state I wanted by doing these things. 但是经过几次尝试,我通过做这些事情达到了想要的状态。

Props to Seth Robertson git choose-your-own-adventure for the "cherry-pitting" command. 塞斯·罗伯森(Seth Robertson)的道具git“樱桃进站”命令选择了自己的冒险方式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Git rebase 功能分支在向开发/主分支的拉取请求中弄乱了提交 - Git rebase feature branch messes up commits in pull request to develop/master branch 变基和更改分支包括请求请求中的所有合并提交 - Rebase and changing branch is including all merged commits in pull request git以交互方式对我的分支上的所有提交进行重新设置 - git rebase interactively all commits on my branch since master 在拉取请求之前强制将基础/合并母版转移到功能分支 - Force rebase/merge master to feature branch before pull request 使用master从master删除了提交的基础为分支建立基础 - Rebase a branch with master with commits removed from master 拉取请求包含我在其他分支上的提交? - Pull request contains my commits on other branch? 仅使用我的提交创建分支/拉取请求 - Create branch / pull request with only my commits 我可以在不影响我的`master`分支的历史记录的情况下,在GitHub pull请求中更改提交的作者吗? - Can I change the author of commits in a GitHub pull request without affecting history of my `master` branch? Git:提交到我的master分支,我打开了pull请求,但现在无法实现新功能 - Git: made commits to my master branch i opened pull request and now can't implement new features 从 dev 到 master 分支的拉取请求不显示差异但提交 - Pull request from dev to master branch doesnt show diff but commits
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM