狠狠撸

狠狠撸Share a Scribd company logo
-p
unleash git’s hidden interactive mode
Alison Rowland (@arowla), 18F Engineering Team Talks
2015/05/18
diffs everywhere!
$ git log
$ git log <filename>
$ git log -p
$ git log -p <filename>
how focused are your commits
?
Good git commit hygiene
● focused
● single feature/change
● log message says
○ “what”
○ “why”
For clean commits,
$ git add -p .
Secret Interactive Git Toolbox
Add to index:
$ git add -p .
Remove from index:
$ git reset -p HEAD
Remove from working tree:
$ git checkout -p .
Any of these can also be applied to specific files.
git’s undo button
$ git checkout -p .
cool stash trick
$ git add -p .
$ git stash --keep-index
QUESTIONS?
alison.rowland@gsa.gov
@arowla

More Related Content

The Greatest git Flag of All

Editor's Notes

  • #3: “meh” at left, “happy” at right, they already know this-- commands at right are useful, not found on github
  • #4: step back, ask a question. how focused are your commits? how often does this happen to you? working on a feature, realize you’ve added two or three, or added a refactor, etc. These could be split into a) other feature branches, or b) just separate commits (commit messages can provide valuable documentation)
  • #6: note that the “index” is where things are put when you “stage” them
  • #9: only way to do selective stash