将文件的特定行提交给 git

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4309156/
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-10 09:34:01  来源:igfitidea点击:

Commit specific lines of a file to git

git

提问by erikvold

Possible Duplicate:
How can I commit only part of a file in git

可能的重复:
如何在 git 中只提交文件的一部分

How do I commit a few specific line ranges from a file to git? while ignoring some other line changes in the same file.

如何将文件中的一些特定行范围提交到 git?同时忽略同一文件中的其他一些行更改。

回答by Adam DiCarlo

Try git add -p-- it will interactively let you add, skip, or split diff hunks.

试一试git add -p——它将以交互方式让您添加、跳过或拆分差异块。

回答by Peter Coulton

Use git add -ito stage the lines then commit as normal, or use git-colauntil you get used to the command line.

使用git add -i到舞台上线,然后提交正常,或使用Git的可乐,直到你习惯了命令行。

Staging lines of a file

文件的暂存行