As the the title says, how to stage a hunk or line using TortoiseGit ?

I did my research and it says something like "click restore after commit" but I still don't know how to do it. Maybe you guys can guide me step by step on how to do it? Thanks.

有帮助吗?

解决方案

stage hunk or lines means git add --patch.
And it is implemented in TortoiseGit (issue 222, TortoiseGit 1.7.7.0), even though it isn't completely satisfactory.

Would've been better if it worked by inclusion instead of exclusion...

You can also create a patch (see "TortoiseGit: apply patch skips added files") and apply it to your index.

Both solutions seems to generate a commit, though, not to modify the index before a commit.


user5534993 adds in the comments:

Right click on the file and use "Context Menu" -> "Restore after commit".

This will create a copy of the file as it is.
Then you can edit the file, e.g. in TortoiseMerge and undo all the changes you don't want to commit.

After saving those changes you can commit the file.
After the commit is done, the copy of the file is restored automatically, and you have the file with all your modifications that were not committed back.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top