简体   繁体   English

进行了git commit,git pull并将我的更改推送到了仓库。 我如何发送对我提交的请求的请求

[英]did a git commit, git pull and pushed my changes to the repo. How can i send a Pull request for the one that i committed

I was searching for this across web, but couldn't find a solution. 我在整个网络上进行搜索,但是找不到解决方案。 Here is my scenario, 这是我的情况

1) I did my local changes. 1)我做了本地更改。 Did a git commit. 进行了git commit。 This will get a commit id say ABC 这将得到一个提交ID说ABC

2) Now I did a git pull from my upstream. 2)现在我从上游进行了git pull。 This had a merge conflict and after resolving it created a commit for the same. 这有一个合并冲突,解决后,创建了一个相同的提交。

3) Now i push these to my origin. 3)现在我把这些推到我的原点。 From the origin i have to send a Pull request to my upstream. 从原点开始,我必须向我的上游发送拉取请求。

4) While trying to send a Pull request, I see both these commits. 4)在尝试发送Pull请求时,我看到了这两个提交。

How can i now send only the commit that i did, that is the commit ABC (from step# 1) 现在如何仅发送我所做的提交,即提交ABC(来自步骤1)

Pull requests are made between branches - you ask the target repo's owner to pull one of your branches to one of his. 分支之间进行拉取请求-您要求目标存储库的所有者将您的一个分支拉到其之一。

If you want to make a pull request consisting in just a single commit, then you have to get a branch that only differs in that commit with the target one. 如果要发出仅包含一次提交的拉取请求,则必须获得一个分支,该分支仅与目标提交不同。

The best thing you can do now, I think, is git fetch your upstream remote, and then create a branch starting from one of it's branches. 我认为,您现在可以做的最好的事情是git fetch您的上游远程服务器,然后从其中一个分支开始创建一个分支。 You'd normally branch off upstream/master (but it could be a different branch if you are not targeting master in your pull request). 通常,您会分支到upstream/master (但是,如果您未在拉取请求中定位master ,则可以是其他分支)。 The command git checkout -b my-feature upstream/master would do the trick - provided those names match the ones you have. git checkout -b my-feature upstream/master可以解决问题-只要这些名称与您的名称匹配。

If that worked, you're now on a brand new branch called my-branch , that points to the very same commit your upstream 's master branch points to. 如果这行得通,那么您现在位于一个名为my-branch全新分支上,该分支指向upstreammaster分支指向的同一提交。 At this moment, you can git cherry-pick that single commit you wanted to appear in the PR (or you could manually edit the files and git commit again, as you'd prefer - the key is you get your commit done over there). 此时,您可以git cherry-pick您想要出现在PR中的单个提交(或者您可以根据需要选择手动编辑文件并再次git commit -关键是您可以在那里完成提交) 。 And now, as you have this new commit in the feature branch, git push your branch to your own repo (say, git push origin my-feature ). 现在,当您在feature分支中具有此新提交时, git push您的分支git push送到您自己的仓库(例如, git push origin my-feature )。 That would create (if it didn't exist, which would be the best) the my-feature branch in your origin repository, and now you can go create the pull request from my-feature to the master branch in upstream . 这样会在origin存储库中创建(如果不存在,那将是最好的) my-feature分支,现在您可以创建从my-featureupstream master分支的拉取请求。


From what you tell, the problem seems to be that you git pull ed your branch - creating that merge commit - instead of using git rebase . 据您所知,问题似乎在于您git pull分支-创建了合并提交-而不是使用git rebase That way, git would automatically tried to cherry-pick your commit on top of the target branch (say, upstream/master ), and there wouldn't have appeared any merge commit. 这样,git会自动尝试在目标分支(例如, upstream/master )上cherry-pick您的提交,并且不会出现任何合并提交。

Anyway, never forget that git rebase is dangerous , and you shouldn't use it if you don't fully understand it . 无论如何,永远不要忘记git rebase是危险的如果您不完全了解它,就不要使用它 You'd better learn more about it first , and then start guessing when and how it would be nice to use it. 你最好了解 更多 关于 的第一 ,然后开始猜测何时,怎么会是很好的使用它。

If it has to be just one thing, don't ever forget the rule of thumb: never rebase public commits. 如果这仅仅是一件事,那就永远不要忘记经验法则:永远不要为公共提交重新设置基准。

暂无
暂无

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

相关问题 有人从git存储库中取消跟踪文件。 Git Kraken用户在提取最新提交时如何将文件保存在本地? - Someone untracked a file from a git repo. How can the Git Kraken users keep the file locally when they pull the most recent commit? 推到git裸仓库,我无法从其他机器上提取更改 - Pushed to git bare repo and I can't pull changes from other machines 为什么运行`git pull`删除我提交的更改? - Why did running `git pull` remove my committed changes? 当提交被推送到GitHub时,Git拉回购 - Git Pull on repo when a commit is pushed to GitHub GIT:我的队友无法提取我推送的更改 - GIT: My Teammate cannot pull the changes I pushed git显示我删除了我的repo中的所有文件,并在我执行git pull之后将它们暂存。 为什么? - git shows that I deleted all the files in my repo and staged them for commit after I did a git pull. Why? 如何使用 git 从提交或拉取请求中提取文件路径和更改? - How can I extract filepaths and changes from a commit or pull request using git? 如何获取具有最新更改的不同存储库并将我的更新也保留在 git 上? - How can I pull in a different repo with the latest changes and keep my updates too on git? 创建了一个git remote,它指向一个外部git repo。 拉动时权限被拒绝 - Created a git remote which points to an external git repo. Permission denied when I do a pull 如何指定GIT拉取必须忽略一些未提交的本地更改? - How can I specify that a GIT pull have to ignore some not committed local changes?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM