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.

  • Git - Merging changes from one feature branch into another between developers
  • How to ignore all files in a folder with a git repository in SourceTree?
  • Refresh code without overwriting my changes
  • Does Git delete empty folders?
  • Git stuck at deltafying objects
  • remove waiting push in sourcetree
  • How do I Uncommit changes using git
  • Git - clone only part of the repository and get pulls only for that part?
  • How can I set this precommit msg hook for Github?
  • Github: Mirroring gh-pages to master
  • completely removing a file from git repo (from a certain point in time)
  • Rewrite git repository history by deleting all files but “foo” and “bar”
  • 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:

    enter image description here

    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.

    Git Baby is a git and github fan, let's start git clone.