简体   繁体   English

如何对 github 项目执行多个拉取请求

[英]How to do multiple pull requests to github project

I have always worked with git and opensrc in a very simple limited way我一直以非常简单的有限方式使用 git 和 opensrc

  • I fork the project in github我在github 中fork项目
  • I git clone my fork to my computer我的叉子克隆到我的电脑上
  • I make some changes on my computer我在我的电脑上做了一些改变
  • I commit the changes提交更改
  • I push to my github fork送到我的 github fork
  • I create pull request from my github fork to the original project我从我的github fork 创建拉取请求到原始项目

This works for a single change.这适用于单个更改。

If I make more changes on my computer and commit them and push before the pull request is accepted then they get added to the same pull request.如果我在我的计算机上进行更多更改并在接受拉取请求之前提交它们并推送,那么它们将被添加到同一个拉取请求中。 I know this is not ideal so I try and wait for first pull request to be accepted before making further changes but this is not always possible.我知道这并不理想,所以我尝试等待第一个拉取请求被接受,然后再进行进一步的更改,但这并不总是可能的。

So I understand that ideally you are meant to create separate branches for each bug fix.所以我理解,理想情况下,您应该为每个错误修复创建单独的分支。 So I made a new branch, made changes, committed the changes and pushed them back to github.所以我创建了一个新分支,进行了更改,提交了更改并将它们推回了 github。 But i cant see this new branch on github and I am not sure hwhat I am meant to do next ?但是我在 github 上看不到这个新分支,我不确定接下来要做什么?

When I run git push on this new branch I get当我在这个新分支上运行git push 时,我得到

ubuntu@ip-172-31-39-147:~/code/discogs-xml2db/speedup$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

I didn't get this when I pushed on the other branch, does this mean the push has not actually happened ?我在另一个分支上推送时没有得到这个,这是否意味着推送实际上没有发生?

Update so I tried Schwerns advice, the command as is didn't quite work but adding setup upstream origin did work it the changes were pushed to github, and I now see this new branch on github.更新所以我尝试了 Schwerns 的建议,命令原样不太有效,但添加setup upstream origin确实起作用了,更改被推送到 github,我现在在 github 上看到了这个新分支。

ubuntu@ip-172-31-39-147:~/code/discogs-xml2db/speedup$ git config --global push.default simple
ubuntu@ip-172-31-39-147:~/code/discogs-xml2db/speedup$ git push
fatal: The current branch releasestatus has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin releasestatus

ubuntu@ip-172-31-39-147:~/code/discogs-xml2db/speedup$ ^C
ubuntu@ip-172-31-39-147:~/code/discogs-xml2db/speedup$  git push --set-upstream origin releasestatus
Username for 'https://github.com': ijabz
Password for 'https://ijabz@github.com':
Counting objects: 17, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 600 bytes | 0 bytes/s, done.
Total 6 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), completed with 5 local objects.
remote:
remote: Create a pull request for 'releasestatus' on GitHub by visiting:
remote:      https://github.com/ijabz/discogs-xml2db/pull/new/releasestatus
remote:
To https://github.com/ijabz/discogs-xml2db.git
 * [new branch]      releasestatus -> releasestatus
Branch releasestatus set up to track remote branch releasestatus from origin.

I don't think you ever pushed your changes to Github.我认为您从未将更改推送到 Github。 Git is telling you it's not fully configured and you need to fix that. Git 告诉你它没有完全配置,你需要修复它。

git push actually has two more parts: where to push to (the "remote"), and which branch to push to. git push实际上还有两个部分:推送到哪里(“远程”),以及推送到哪个分支。 When you're on your master branch git push is really git push origin master .当你在你的主分支上git push真的是git push origin master The remote repository you cloned from is called "origin" and Git knows your master branch came from it's master branch.您从中克隆的远程存储库称为“origin”,Git 知道您的 master 分支来自它的 master 分支。

When you make a new branch, Git doesn't know where you want to push it to.当你创建一个新分支时,Git 不知道你想把它推到哪里。 If you run git push on your new branch it will have to guess.如果您在新分支上运行git push ,它将不得不猜测。 push.default tells Git how to guess, and it's not set. push.default告诉 Git 如何猜测,它没有设置。

You can read git-config to learn more about the options, but I recommend setting it to simple .您可以阅读git-config以了解有关选项的更多信息,但我建议将其设置为simple It will guess that you want to push it to a branch with the same name as your own.它会猜测您想将其推送到与您自己的名称相同的分支。

git config --global push.default simple

Now you should be able to git push to Github.现在你应该可以git push到 Github。

You can also spell it out for Git: git push origin <name of your branch> .您也可以为 Git 拼写: git push origin <name of your branch>

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM