Is it possible in SourceTree commit only one “hunk” of changes?
Is it possible in sourcetree commit only one “hunk” of changes? As I see I can dismiss a “hunk” of changes, but I can not commit them.
One Solution collect form web for “Is it possible in SourceTree commit only one “hunk” of changes?”
Yes, you can selectively stage blocks (also known as “hunks”) of code to be committed using git and SourceTree. Here is an example:
In the image above, I have selected to view changes in my working copy. 2 hunks are displayed. In the first hunk, I selected 2 specific lines, which I can then selectively stage to be committed. Note that you can only stage consecutive lines at a time with this method, so if you want to selectively stage non-consecutive lines, you have to select them 1 at a time.
For the 2nd hunk, instead of staging individual lines, I can instead choose to stage the entire hunk.
After you’re done staging the lines or hunks of code that you want, anything remaining unstaged changes will remain in your working copy, but won’t be committed until you stage them too. It is in this way that you can selectively pick lines or hunks of code to be committed from your modified working copy.