Git 和 Intellij,如何仅提交已更改文件的一部分

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

Git & Intellij, How do I commit only parts of a changed file

gitintellij-ideagit-commit

提问by Jordan

I can't seem to commit only a fraction of the changes in a file, it seems to be all of the file or nothing, I'm using Git with Intellij, is it possible?

我似乎不能只提交文件中的一小部分更改,它似乎是整个文件或什么都没有,我正在将 Git 与 Intellij 一起使用,这可能吗?

Thanks.

谢谢。

采纳答案by khagler

Not in the IDE. As noted in comments, you can use the command line, but I find it much easier to use a GUI GIT client (I use Tower, but there are many available).

不在 IDE 中。如评论中所述,您可以使用命令行,但我发现使用 GUI GIT 客户端要容易得多(我使用Tower,但有很多可用)。

回答by Sean Lynch

Update - 2/2018:The first EAP build for 2018.1 has landed and it's HERE! It is implemented as checkboxes for each hunk, so you can selectively check on them before making the commit. Enjoy!

更新 - 2/2018:2018.1的第一个 EAP 版本已经登陆,它就在这里!它被实现为每个大块的复选框,因此您可以在提交之前有选择地检查它们。享受!

Update - 12/2017:

更新 - 12/2017:

Well 2017.3 was just released and this didn't make it in. So let's hope for 2018.1.

好吧,2017.3 刚刚发布,但没有成功。所以让我们对 2018.1 抱有希望。

Update - 11/2017:

更新 - 11/2017:

This has been 'in progress' for months now. The 2017.3 EAP releases have been coming out for a while but this issue hasn't been finished yet. With no updates to the issue other than people asking when it will be done, I'm thinking this will slip to the 2018 release.

这已经“进行”了几个月了。2017.3 EAP 版本已经发布了一段时间,但这个问题还没有完成。除了人们询问何时完成之外,该问题没有任何更新,我认为这将推迟到 2018 年发布。

Update - 2017:

更新 - 2017 年:

This issuehas been open for years as noted in some of the comments. But it is now in progress and sheduled to land in 2017.3 which is currently in EAP release and should be available this fall. So now, four years after this was asked, you will soon be able to actually do it right in the IDE.

正如一些评论中所指出的,这个问题已经存在多年。但它现在正在进行中,预计将于 2017.3 登陆,目前正在 EAP 版本中,应该会在今年秋天上市。所以现在,在提出这个问题四年后,您很快就能在 IDE 中真正做到这一点。

回答by Andres Canella

You should try SourceTree(Mac & Windows), It's free and a great tool for working with GIT. It has all the commit freedom you want in a confortable UI.

你应该试试 SourceTree(Mac & Windows),它是免费的,是一个很好的使用 GIT 的工具。它在舒适的用户界面中拥有您想要的所有提交自由。

This is my commit workflow for IntelliJ, from simple to complex task:

这是我的 IntelliJ 提交工作流程,从简单到复杂的任务:

  1. IntelliJ
  2. SourceTree
  3. shell GIT.
  1. 智能
  2. 源树
  3. 壳 GIT。

回答by David Leitner

The wait is finally over, partial commits are part of EAP 18.1: https://blog.jetbrains.com/idea/2018/02/intellij-idea-2018-1-eap-partial-git-commits-and-more/

等待终于结束,部分提交是 EAP 18.1 的一部分:https: //blog.jetbrains.com/idea/2018/02/intellij-idea-2018-1-eap-partial-git-commits-and-more/