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

Leveling up your git skills

Leveling up your git skills

This talk is designed to help those who know a little bit about git and give them a bit of knowledge and some confidence to level up those skills.

Chris Keathley

May 06, 2017
Tweet

More Decks by Chris Keathley

Other Decks in Programming

Transcript

  1. $ git checkout c652b6b Note: checking out 'c652b6b'. You are

    in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b <new-branch-name> HEAD is now at c652b6b... Add kubernetes setup to fish shell.
  2. $ hg merge --help --verbose | wc -w # =>

    327 $ git merge --help | wc -w # => 3958
  3. Git

  4. alias g='git' alias gaa='git add -A' alias gb='git branch' alias

    gc='git commit' alias gco='git checkout' alias gd='git diff' alias gglr='git pull --rebase' alias ggp='git push' alias gst='git status'
  5. alias wip='git add -A && git commit -m "WIP"' alias

    gc!='git commit -v --amend' alias ggp!='git push --force'
  6. alias ibase='git rebase -i $(git merge-base HEAD master)' alias gpr='git

    pull-request -o' alias gcm='git remote show origin \ | awk '/HEAD branch:/ {print \$3}' \ | xargs git checkout'
  7. Git Scripts λ git guilt "Grace Hopper" "[email protected]" You need

    a passphrase to unlock the secret key for user: "Chris Keathley <[email protected]>" 4096-bit RSA key, ID EA3A16BD, created 2017-04-23 [test-branch 0beb550] New file for demo Author: Grace Hopper <[email protected]> Date: Wed May 3 21:54:10 2017 -0400 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 new_file
  8. λ git bisect start HEAD HEAD~10 Start a new bisect

    The “bad” revision The “Good” revision
  9. λ git bisect bad 6fb10e5ec916063e4b4bd744678559afb45d6791 is the first bad commit

    commit 6fb10e5ec916063e4b4bd744678559afb45d6791 Author: Aaron Renner <[email protected]> Date: Tue May 2 07:55:01 2017 -0600 Fix leaking webdriver sessions in QueryTest (#209) Wallaby.Integration.QueryTest was starting a ton of sessions and not cleaning them up. This switches it over to use Wallaby.Integration.SessionCase and uses the session that's automatically created and cleaned up. I also extracted the unit tests out of this integration test so they can be run separately.
  10. $ git checkout master $ git pull --rebase $ git

    checkout -b feature/my-fancy-form-123456
  11. $ git add -A && git commit -m "WIP" $

    git push -u origin HEAD Wip && Push
  12. $ git checkout master $ git pull —rebase $ git

    checkout -b bugs/put-out-server-fire
  13. $ git checkout master $ git pull --rebase $ git

    checkout - $ git rebase master
  14. $ git checkout master $ git pull --rebase $ git

    checkout - $ git rebase master
  15. $ git checkout master $ git pull --rebase $ git

    checkout - $ git rebase master
  16. $ git checkout master $ git pull --rebase $ git

    checkout - $ git rebase master
  17. λ git rebase master First, rewinding head to replay your

    work on top of it... Applying: My Fancy Fix Using index info to reconstruct a base tree... M README.md Falling back to patching base and 3-way merge... Auto-merging README.md CONFLICT (content): Merge conflict in README.md error: Failed to merge in the changes. Patch failed at 0001 WIP The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git rebase --continue". If you prefer to skip this patch, run "git rebase --skip" instead. To check out the original branch and stop rebasing, run "git rebase --abort".
  18. λ git rebase master First, rewinding head to replay your

    work on top of it... Applying: My Fancy Fix Using index info to reconstruct a base tree... M README.md Falling back to patching base and 3-way merge... Auto-merging README.md CONFLICT (content): Merge conflict in README.md error: Failed to merge in the changes. Patch failed at 0001 WIP The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git rebase --continue". If you prefer to skip this patch, run "git rebase --skip" instead. To check out the original branch and stop rebasing, run "git rebase --abort".
  19. λ mix test 1) test it works (Metaform.Web.PageViewTest) test/web/views/page_view_test.exs:4 This

    is broken now stacktrace: test/web/views/page_view_test.exs:5: (test) .... Finished in 0.1 seconds 5 tests, 1 failure
  20. f1b1 HEAD@{0}: rebase -i (finish): returning to refs/heads/chores/remove-select 677f1b1 HEAD@{1}:

    rebase -i (pick): Update new file f55b0d8 HEAD@{2}: cherry-pick: fast-forward f4b7d8b HEAD@{3}: rebase -i (start): checkout HEAD~3 ca47093 HEAD@{4}: commit: Update new file 039d19a HEAD@{5}: commit (amend): My super important commit don't loose this. 62fc606 HEAD@{6}: rebase -i (finish): returning to refs/heads/chores/remove-select
  21. f1b1 HEAD@{0}: rebase -i (finish): returning to refs/heads/chores/remove-select 677f1b1 HEAD@{1}:

    rebase -i (pick): Update new file f55b0d8 HEAD@{2}: cherry-pick: fast-forward f4b7d8b HEAD@{3}: rebase -i (start): checkout HEAD~3 ca47093 HEAD@{4}: commit: Update new file 039d19a HEAD@{5}: commit (amend): My super important commit don't loose this. 62fc606 HEAD@{6}: rebase -i (finish): returning to refs/heads/chores/remove-select
  22. CLI