git 如何从拉取请求中排除文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15392003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:19:01  来源:igfitidea点击:

How to exclude files from a pull request?

gitpull-request

提问by Cory

I will like to perform a pull and merge request but also I would like to exclude some files from this pull request.

我想执行一个拉取和合并请求,但我也想从这个拉取请求中排除一些文件。

Example: a.py  b.py c.py

I would like to peform a pull request and merge except b.pyfile.

我想执行拉取请求并合并除b.py文件。

What is the easiest way to accomplish this?

实现这一目标的最简单方法是什么?

[edit] the file is not committed it yet.

[编辑] 该文件尚未提交。

回答by CharlesB

Make two branches from where you are right now, for example my-pull-requestand other-change.

从您现在所在的位置创建两个分支,例如my-pull-requestother-change

Commit a.py and c.py to my-pull-request, and b.py to other-change. Push the my-pull-requestbranch to Github, and create the pull request.

将 a.py 和 c.py 提交到my-pull-request,并将 b.py 提交到other-change。将my-pull-request分支推送到 Github,并创建拉取请求。

回答by favoretti

Commit a.pyand c.py, git stashthe rest, perform the request, then git stash popto restore your b.py

提交a.pyc.pygit stash剩下的,执行请求,然后git stash pop恢复你的b.py

回答by edaype

Try pulling all the files and reverse the files to a specific commit. Then push your changes if you want. You can also stack your changes, pull and then apply your stack

尝试拉取所有文件并将文件反转到特定提交。然后根据需要推送您的更改。您还可以堆叠您的更改,拉取然后应用您的堆栈