Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git In A Tree

Git In A Tree

An illustrated guide to Git

Daniel Öberg

November 13, 2011
Tweet

Other Decks in Programming

Transcript

  1. Save git commit -m “I wrote ‘Duck’ into README.txt” Staging

    Area README.txt Duck Commit commit message
  2. Reason Splits your code into two sections: Code that has

    been reviewed for a commit Code that hasn’t
  3. Reason Splits your code into two sections: Code in the

    staging area Code not in the staging area
  4. I’m happily coding echo "bug-fix" >> README.txt echo "new feature"

    >> README.txt cat README.txt duck bug-fix new feature
  5. Committing the feature only git add --patched README.txt && git

    commit -m “Feature added” Staging Area README.txt new feature Commit Duck new feature new feature
  6. Seeing what’s left git diff @@ -1,2 +1,3 @@ duck

    +bug-fix new feature Really, really useful
  7. Committing that git add README.txt && git commit -m “Bug

    squashed” Staging Area README.txt bug-fix Commit Duck new feature bug-fix bug-fix
  8. Send Specific Patch Now I can freely choose to send

    a patch that contains only the bug-fix to my boss (he can have the new feature on his birthday). Duck new feature bug-fix
  9. Remove Specific Patch ‘New feature’ might have contained a serious

    bug. I can the remove the new feature without touching the bug-fix. Amazing, you say. Duck new feature bug-fix
  10. git add --patch Adds some part (it will ask you)

    of the files to the staging area. Staging Area README.txt new feature
  11. git rm Removes all the files content from the staging

    area. Staging Area README.txt Duck
  12. git diff Shows the difference between the staging area and

    the working directory. Staging Area README.txt Diff
  13. git commit -m “msg” Commit file content in staging area

    with a description/message Staging Area README.txt Commit *
  14. git add Git has a list of files. By running

    git add you also append the filenames given to this list. Nasty, nasty, nasty. Lots of confusion from this feature.
  15. git commit -a This is the reason for tracking the

    files. By adding an -a you tell git to add all its tracked files file contents to the staging area and then commit it all.