简体   繁体   English

如何在我的Git分支的本地副本中使用拉取请求?

[英]How to use a pull request in my local copy of a Git branch?

I'm not familiar with Git, I only know how to download a master or dev branch of a python software project from Github and install into my system (I do not really use Git locally). 我不熟悉Git,我只知道如何从Github下载python软件项目的master或dev分支并将其安装到我的系统中(我并不真正在本地使用Git)。
Now there is a "pull request" by a GitHub user which contains a feature I find useful but not in the main or dev branch. 现在,GitHub用户有一个“拉取请求”,其中包含我认为有用的功能,但不适用于main或dev分支。 How can I use that in my local copy? 如何在我的本地副本中使用它?
And if I manage to include it into my local copy, would it be lost if I later updated to the latest maaster/dev branch? 而且,如果我设法将其包含在本地副本中,那么如果以后更新到最新的maaster / dev分支,它会丢失吗?

see: Git fetch remote branch 请参阅: Git获取远程分支

git fetch

git checkout  <the name of the remote branch>

You can revert to any commit anytime you want, those changes are kept in the repository so you can visit different versions of it during the development on all branches. 您可以随时还原为任何提交,这些更改都保存在存储库中,因此您可以在开发过程中在所有分支上访问其不同版本。 You need to do a merge command, which if, there's not any conflict with the patch contained in the pull request, will combine the code of the patch with the code of the repository. 您需要执行合并命令,如果与pull请求中包含的补丁程序没有任何冲突,它将合并补丁程序的代码和存储库的代码。 If there's conflicting code, like shared files for example, you will have to do the proper refactors and select which changes get inside or not. 如果存在冲突的代码(例如,共享文件),则必须进行适当的重构,并选择将哪些更改纳入内部或不进行更改。

Here you have basic information about merging different branches: 在这里,您可以获得有关合并不同分支的基本信息:

http://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging http://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging

Updating will only do a merge with the changes and your master. 更新只会合并更改和您的母版。 If you break something you can stash the changes and get to the original state. 如果您破坏了某些内容,则可以存储更改并恢复到原始状态。 Also I would suggest to checkout a fresh branch and apply that feature on the freshly created branch. 我也建议您检出一个新的分支并将该功能应用到新创建的分支上。 If every thing works fine merge it to your master otherwise delete and forget it :P 如果一切正常,将其合并到您的主机,否则删除并忘记它:P

if you dont know the branch name use git fetch first to know the branch name and then git checkout 如果您不知道分支名称,请先使用git fetch知道分支名称, then git checkout

Also maybe you can find this link useful 另外也许您会发现此链接有用

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

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