Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Git, The Good Stuff

229 views

Published on

Git details for cherry-picking, squashing, rebasing, patch files and more

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Git, The Good Stuff

  1. 1. Git, The Good Stuff Phil Palmieri
  2. 2. What We Are Covering - Git Log - Rebasing - Squashing - Cherry-Picking - Patch Files - Reverting and Oh S!#t now what do I do?
  3. 3. Anatomy of the log - %> git log - Every commit has a unique hash - Every hash has a - diff / files - date - author - message
  4. 4. Git Log Options - Git log any branch by appending “git log [branch name]” - %> git log --stat (shows files) - --since/after=[date] - --until/before=[date] - --grep=[regex] - --graph (pretty graph)
  5. 5. Git Log Format - %> git log --format=[oneline|short|medium|full] - %> git log --format=”custom %h formatting” - %h [short hash] - %an [author name] - %ar [date relative] - %C [color] full list at https://git-scm.com/docs/git-log
  6. 6. Viewing a commit / hash %> git show [hash]
  7. 7. Rebasing %> git rebase [branch] re-stacking the deck 3 1 - 2 1 2 1 2 2 2 2 3 1 1 1
  8. 8. Combining (squashing) commits %> git rebase -i HEAD~2 - will rebase interactive the last 2 commits - change hash to ‘s’ to squash multiple commits - update messages 3.2 3.1 3 2 1 3 2 1
  9. 9. Cherry-Picking %> git cherry-pick [hash] creates a copy of a commit on one branch to another. - very good for copying code to a Q/A server
  10. 10. Create a ‘Simple’ Patch File %> git show [hash1] > ~/mypatch.patch %> git show [hash2] >> ~/mypatch.patch (append) %> git apply ~/mypatch.patch
  11. 11. Undo / Oh S#%t button %> git reset --hard HEAD ----------------------------------------------- %> git reset --hard HEAD^^^^^^^ (rollback a few commits) %> git pull
  12. 12. Undo Your Commit %> git revert [hash] Did your code/commit break something - undo it. note: You can revert a revert to put it back
  13. 13. Git Blame (who wrote that code?) %> git blame [file] Will show you who changed each line of the file

×