Smacking Git Around Advanced Git Tricks

  • View
    4.576

  • Download
    7

Embed Size (px)

DESCRIPTION

 

Text of Smacking Git Around Advanced Git Tricks

  • Smacking Git Around by Scott Chacon
  • Me
  • Scott Chacon
  • github.com/schacon
  • Scott Chacon has an understandable but borderline unhealthy obsession with Git - Ilya Grigorik igvita.com
  • git-scm.com
  • book.git-scm.com
  • schacon@gmail.com
  • previously, on Git...
  • GIT
  • Git
  • image by matthew mccullough
  • Scott Chacon Scott Scott Chacon is a Git v1 v2 v3
  • 98ca9.. 34ac2.. f30ab.. commit commit commit size size size tree tree tree 0de24 184ca 92ec2 author parent parent Scott 98ca9 34ac2 committer author author Scott Scott Scott committer committer initial commit of my project Scott Scott fixed bug #1328 - stack add feature #32 - ability to overflow under certain add new formats to the central snapshot A snapshot B snapshot C
  • 98ca9.. e8455.. commit size blob size 0de24.. 0de24.. tree 0de24 == LICENSE: tree size parent nil (The MIT License) author Scott blob e8455 README Copyright (c) 2007 Tom Preston- committer Scott tree 10af9 lib Permission is hereby granted, f my commit message goes here ree of charge, to any person ob and it is really, really cool bc52a.. 10af9.. blob size tree size require 'grit/index' blob bc52a mylib.rb require 'grit/status' tree b70f8 inc module Grit class > test $ git commit -m C2 topic C2 master C1
  • $ echo version three >> test $ git commit -m C3 topic C3 C2 master C1
  • $ git checkout master $ echo version four >> test $ git commit -m C4 topic C3 master C4 C2 C1
  • $ echo version five >> test $ git commit -m C5 master topic C5 C3 C4 C2 C1
  • master topic $ git diff topic C5 C3 C4 C2 C1
  • master topic what does topic have $ git diff topic C5 C3 that I dont have? C4 C2 C1
  • master topic what would happen if I $ git diff topic C5 C3 merged in topic? C4 C2 C1
  • master topic how do I make topic $ git diff topic C5 C3 look like HEAD? C4 C2 C1
  • $ git diff topic diff --git a/test b/test master topic index 304313d..bd8c6c9 100644 --- a/test +++ b/test C5 C3 @@ -1,3 +1,3 @@ version one -version two -version three C4 C2 +version four +version five C1
  • $ git diff topic diff --git a/test b/test master topic index 304313d..bd8c6c9 100644 --- a/test +++ b/test C5 C3 @@ -1,3 +1,3 @@ version one -version two -version three C4 C2 +version four +version five C1
  • $ git diff HEAD topic diff --git a/test b/test master topic index bd8c6c9..304313d 100644 --- a/test +++ b/test C5 C3 @@ -1,3 +1,3 @@ version one -version four -version five C4 C2 +version two +version three C1
  • $ git diff HEAD topic diff --git a/test b/test master topic index bd8c6c9..304313d 100644 --- a/test +++ b/test C5 C3 @@ -1,3 +1,3 @@ version one -version four -version five C4 C2 +version two +version three C1
  • git diff HEAD topic
  • git diff HEAD...topic
  • git diff HEAD...topic
  • $ git diff HEAD topic master topic C5 C3 C4 C2 C1
  • $ git diff HEAD topic master topic C5 C3 C4 C2 C1
  • $ git diff HEAD...topic master topic C5 C3 C4 C2 C1
  • $ git diff HEAD...topic diff --git a/test b/test master topic index 9bc69cf..304313d 100644 --- a/test +++ b/test @@ -1 +1,3 @@ C5 C3 version one +version two +version three C4 C2 C1
  • $ git diff HEAD...topic diff --git a/test b/test master topic index 9bc69cf..304313d 100644 --- a/test what would happen if I +++ b/test @@ -1 +1,3 @@ C5 C3 merged in topic? version one +version two +version three C4 C2 C1
  • Data Munging
  • Rewriting History
  • Modifying the last commit
  • git commit --amend
  • Rebasing
  • master topic C5 C3 C4 C2 C1
  • topic C6 master C5 C3 C4 C2 C1 git merge master
  • master topic C5 C3 C4 C2 C1 git rebase master
  • master topic C5 C3 C4 C2 C1 git rebase master