Support patch adding in Visual Studio Tools for Git
Patch adding allows to stage only parts of a file (hunks), not an entire file.
The command line equivalent is the command "git add --patch"
For example if you edit a file on line 20 and make another change on line 40 and now you want to split this changes into two separate commits because they are unrelated to each other you can do this by patch adding the file. It would be nice to have this functionality available inside of Visual Studio.
The same funcionality could be used to automatically include the changed parts of the csproj file when a file is added or deleted, so you never forget to add the csproj file to the corresponding commit.
This would be a great addition to a great tool.
This feature is still sorely missed in Visual Studio 2017.
David Warburton commented
This is the main feature that keeps me from doing all of my git work in visual studio. This feature is important to a healthy git workflow because it helps you to organize your work into different commits which can pass code review individually without having to do extensive planning in advance. Having this feature means you can bravely refactor code as you are fixing bugs and adding new features without the fear that code review concerns on the refactor could introduce delays for the bug or feature that is needed since you'll be able to easily put those things into two independent commits, if Visual Studio had this feature.
Victor Tarnovskiy commented
VS Team, this one is very useful, can you implement this, please?
Joao Vitor P. Moraes commented
This feature is very usefull to me, most of the times I want to review the changes in my files before commiting, and add only what I want to the commit, excluding empty lines and changes that are not meant for a specific commit.
Is very common for me to fix 2 things at the same time,
and being able to select some blocks of the file and do a commit 1,
then select other parts and commit 2.
This is a basic funcionality in git gui, and if this feature is not available I'll still need to open git bash and git gui, making the VS/Git integration somewhat useless.
Commiting the hole file, just by looking at its name, instead of revewing each changed block in the file, results in worse commits, generally (in my opinion).
git gui, solves this problem elegantly, enabling you to select what you do/dont want to commit, showing every line change, and all I have to do is right-click -> stage hunk for commit
I can also stage the line or the hole file, but the big difference is that the changes are in my face in the time of the commit, instead of adding the file by name, and trusting that I've only changed what I think I did (and in my experience this is not the case most of the times).
Enabling the user to select what to commit, block by block (of changes), encourage code review, and leads to better commits.
This in my opinion is a must have funcionality, in any git replacement wannabe.
Aleš Roubíček commented
Add Git support for staging of selected lines