Global Information Tracker (git)

Git commands I like to remember.

Select Hunks Interactively

With git add -p <file> for patch mode the file or files are not just added but you can choose which so called hunks of the changes should staged for commiting.

...
(1/1) Stage this hunk [y,n,q,a,d,s,e,p,?]?
  • y accepts the hunk to be staged.
  • n declines the hunk to be staged.
  • s tries to split the hunk up into smaller pieces.
  • a accepts the hunk and any remaining.
  • d declines the hunk and any remaining.

Forgott a Thing

To change your last commit and add something or fix a typo in the commit messag, use --amend:

git commit -m "initial commit"
git add the_file.txt
git commit --amend

You can now overwrite your previous commit and have just one clean commit.