jackyalciné

Need a hand with tech consulting? I can help!
Learn more about how we can work via black.af .

Commits Hunks in Git

Reading the post on Github about the new feature in Github for Mac that allowed for partial unstaged commits made me wonder if it was a core Git feature. I remember seeing something about it, but it wasn’t a glorified feature. A quick git commit --help showed me what I was looking for; the --interactive switch. There isn’t documentation there directly about it; one would have to go to git-add(1) in the “Interactive Mode” section to learn more about it. It mentions using git add to handle interactive mode as shown:

:pencil: by Jacky Alciné Jacky Alciné :book: an post :bookmark: git , development , tips :clock7: written :eyeglasses: about 1 minute, 208 words :link: Comments - 0 Mention(s) - Permalink

Reading the post on Github about the new feature in Github for Mac that allowed for partial unstaged commits made me wonder if it was a core Git feature. I remember seeing something about it, but it wasn’t a glorified feature. A quick git commit --help showed me what I was looking for; the --interactive switch. There isn’t documentation there directly about it; one would have to go to git-add(1) in the “Interactive Mode” section to learn more about it. It mentions using git add to handle interactive mode as shown:

# Snatched from http://git-scm.com/book/en/Git-Tools-Interactive-Staging
$ git add -i
           staged     unstaged path
  1:    unchanged        +0/-1 TODO
  2:    unchanged        +1/-1 index.html
  3:    unchanged        +5/-1 lib/simplegit.rb

*** Commands ***
  1: status     2: update      3: revert     4: add untracked
  5: patch      6: diff        7: quit       8: help

It shows you a diff of the changes made to a particular file and allows you to continue working from where you left off; definitely helped out quite a few times. I actually have an alias in my dotfiles just for this, a là gci.

alias gci='git commit --interactive'

Happy Gitting!