master
topic
$ git clone https://github.com/Joe-noh/motto_git
$ git checkout -b xxx-topic
$ vim test.rb
$ git commit -am 'modified'
$ git push origin xxx-topic
master
master
topic topic2
master
topic topic2
topic topic2
master
topic topic2
master
topic
master
topic
$ git checkout master
$ git pull origin master # master
$ git checkout xxx-topic
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: modify test.rb
Using index info to reconstruct a base tree...
M test.rb
Falling back to patching base and 3-way merge...
1 class Hoge
2 <<<<<<< HEAD
3 def bar
4 =======
5 def baz
6 >>>>>>> master
7 end
8 end
NORMAL xxx-topic | test.rb
1 class Hoge
2 def bar
3 end
4 end
~
~
~
~
NORMAL xxx-topic | test.rb
$ vim test.rb
$ git add test.rb #
$ git rebase --continue
Applying: modify test.rb
topic
remote
local
topic
topic
topic
remote
local
--force-with-lease
topic(new)
master
topic
base master
topic topic(new)
class Hoge
@v = 1
puts "C"
end
class Hoge
puts "A"
end
class Fuga
puts "B"
end
master base topic topic(new)
class Hoge
@v = 1
puts "C"
end
class Hoge
puts "A"
end
class Fuga
puts "B"
end
master base topic topic(new)
class Hoge
@v = 1
puts "C"
end
class Hoge
puts "A"
end
class Fuga
puts "B"
end
master base topic
end
topic(new)
class Hoge
@v = 1
puts "C"
end
class Hoge
puts "A"
end
class Fuga
puts "B"
end
master base topic
end
topic(new)
class Hoge
@v = 1
puts "C"
end
class Hoge
puts "A"
end
class Fuga
puts "B"
end
master base topic
class Fuga
end
topic(new)
class Hoge
@v = 1
puts "C"
end
class Hoge
puts "A"
end
class Fuga
puts "B"
end
master base topic
class Fuga
end
topic(new)
class Hoge
@v = 1
puts "C"
end
class Hoge
puts "A"
end
class Fuga
puts "B"
end
master base topic
class Fuga
@v = 1
end
topic(new)
class Hoge
@v = 1
puts "C"
end
class Hoge
puts "A"
end
class Fuga
puts "B"
end
master base topic
class Fuga
@v = 1
end
topic(new)
class Hoge
@v = 1
puts "C"
end
class Hoge
puts "A"
end
class Fuga
puts "B"
end
master base topic
class Fuga
@v = 1
?
end
topic(new)
class Hoge
@v = 1
puts "C"
end
class Hoge
puts "A"
end
class Fuga
puts "B"
end
master base topic
class Fuga
@v = 1
?
end
topic(new)
topic(new)
master
topic
$ git checkout master
$ git pull origin master # master
$ git checkout xxx-topic
$ git merge master
Auto-merging test.rb
CONFLICT (content): Merge conflict in test.rb
Automatic merge failed; fix conflicts and then commit the result.
$ vim test.rb
$ git commit -a
1 Merge branch 'master' into xxx-topic
2
3 # Conflicts:
4 # test.rb
5 #
6 # ...
7 # ...
8 # ...
NORMAL xxx-topic | test.rb
$ git push origin xxx-topic
commit 25ce283d9d3c4da27c0226e19654b91c1baf06e3
Author: Joe-noh <honzawa.j@pepabo.com>
Date: Tue Jun 21 12:17:38 2016 +0900
commit f8263df7885c907e34b574524a7fc02702920d44
Author: Joe-noh <honzawa.j@pepabo.com>
Date: Tue Jun 21 12:16:28 2016 +0900
$ git revert 25ce283d #
[topic 1564168] Revert " "
1 file changed, 4 deletions(-)
commit 1564168380ec04480275ecd2b2ed9612001889fb
Author: Joe-noh <honzawa.j@pepabo.com>
Date: Tue Jun 21 12:58:14 2016 +0900
Revert " "
This reverts commit 25ce283d9d3c4da27c0226e19654b91c1baf06e3.
commit 25ce283d9d3c4da27c0226e19654b91c1baf06e3
Author: Joe-noh <honzawa.j@pepabo.com>
Date: Tue Jun 21 12:17:38 2016 +0900
$ git checkout master
$ git pull origin master # master
$ git checkout -b revert-topic #
$ git revert ?????? # revert
$ git push origin revert-topic #
commit 06a1792f1fb01b834d86514d15783eca4352606c
Merge: 97bf260 a392dd9
Author: Joe Honzawa <honzawa.j@pepabo.com>
Date: Mon Jun 20 19:46:10 2016 +0900
Merge pull request #2 from Joe-noh/topic
$ git revert 06a1792
$ git revert 06a1792
error: Commit 06a1792… is a merge but no -m option was given.
fatal: revert failed
$ git revert 06a1792
error: Commit 06a1792… is a merge but no -m option was given.
fatal: revert failed
-m
master
topic
$ git revert 06a1792 -m 1
[topic 3d621f4] Revert "Merge pull request #2 from Joe-noh/topic"
1 file changed, 4 deletions(-)
$ git revert 06a1792 -m 1
[topic 3d621f4] Revert "Merge pull request #2 from Joe-noh/topic"
1 file changed, 4 deletions(-)
$ git push origin revert-topic
git rebase -i <commit hash>
git cherry-pick <commit hash>
master rebase
master merge
git revert <commit>
git revert <merge-commit> -m 1
もっとgit

もっとgit

  • 3.
  • 6.
    $ git clonehttps://github.com/Joe-noh/motto_git $ git checkout -b xxx-topic $ vim test.rb $ git commit -am 'modified' $ git push origin xxx-topic
  • 7.
  • 12.
  • 13.
  • 14.
  • 15.
  • 17.
  • 18.
  • 19.
    $ git checkoutmaster $ git pull origin master # master $ git checkout xxx-topic $ git rebase master First, rewinding head to replay your work on top of it... Applying: modify test.rb Using index info to reconstruct a base tree... M test.rb Falling back to patching base and 3-way merge...
  • 20.
    1 class Hoge 2<<<<<<< HEAD 3 def bar 4 ======= 5 def baz 6 >>>>>>> master 7 end 8 end NORMAL xxx-topic | test.rb
  • 21.
    1 class Hoge 2def bar 3 end 4 end ~ ~ ~ ~ NORMAL xxx-topic | test.rb
  • 22.
    $ vim test.rb $git add test.rb # $ git rebase --continue Applying: modify test.rb
  • 29.
  • 30.
  • 31.
  • 34.
  • 36.
  • 37.
    class Hoge @v =1 puts "C" end class Hoge puts "A" end class Fuga puts "B" end master base topic topic(new)
  • 38.
    class Hoge @v =1 puts "C" end class Hoge puts "A" end class Fuga puts "B" end master base topic topic(new)
  • 39.
    class Hoge @v =1 puts "C" end class Hoge puts "A" end class Fuga puts "B" end master base topic end topic(new)
  • 40.
    class Hoge @v =1 puts "C" end class Hoge puts "A" end class Fuga puts "B" end master base topic end topic(new)
  • 41.
    class Hoge @v =1 puts "C" end class Hoge puts "A" end class Fuga puts "B" end master base topic class Fuga end topic(new)
  • 42.
    class Hoge @v =1 puts "C" end class Hoge puts "A" end class Fuga puts "B" end master base topic class Fuga end topic(new)
  • 43.
    class Hoge @v =1 puts "C" end class Hoge puts "A" end class Fuga puts "B" end master base topic class Fuga @v = 1 end topic(new)
  • 44.
    class Hoge @v =1 puts "C" end class Hoge puts "A" end class Fuga puts "B" end master base topic class Fuga @v = 1 end topic(new)
  • 45.
    class Hoge @v =1 puts "C" end class Hoge puts "A" end class Fuga puts "B" end master base topic class Fuga @v = 1 ? end topic(new)
  • 46.
    class Hoge @v =1 puts "C" end class Hoge puts "A" end class Fuga puts "B" end master base topic class Fuga @v = 1 ? end topic(new)
  • 47.
  • 48.
    $ git checkoutmaster $ git pull origin master # master $ git checkout xxx-topic $ git merge master Auto-merging test.rb CONFLICT (content): Merge conflict in test.rb Automatic merge failed; fix conflicts and then commit the result. $ vim test.rb $ git commit -a
  • 49.
    1 Merge branch'master' into xxx-topic 2 3 # Conflicts: 4 # test.rb 5 # 6 # ... 7 # ... 8 # ... NORMAL xxx-topic | test.rb
  • 50.
    $ git pushorigin xxx-topic
  • 56.
    commit 25ce283d9d3c4da27c0226e19654b91c1baf06e3 Author: Joe-noh<honzawa.j@pepabo.com> Date: Tue Jun 21 12:17:38 2016 +0900 commit f8263df7885c907e34b574524a7fc02702920d44 Author: Joe-noh <honzawa.j@pepabo.com> Date: Tue Jun 21 12:16:28 2016 +0900
  • 57.
    $ git revert25ce283d # [topic 1564168] Revert " " 1 file changed, 4 deletions(-)
  • 58.
    commit 1564168380ec04480275ecd2b2ed9612001889fb Author: Joe-noh<honzawa.j@pepabo.com> Date: Tue Jun 21 12:58:14 2016 +0900 Revert " " This reverts commit 25ce283d9d3c4da27c0226e19654b91c1baf06e3. commit 25ce283d9d3c4da27c0226e19654b91c1baf06e3 Author: Joe-noh <honzawa.j@pepabo.com> Date: Tue Jun 21 12:17:38 2016 +0900
  • 61.
    $ git checkoutmaster $ git pull origin master # master $ git checkout -b revert-topic # $ git revert ?????? # revert $ git push origin revert-topic #
  • 62.
    commit 06a1792f1fb01b834d86514d15783eca4352606c Merge: 97bf260a392dd9 Author: Joe Honzawa <honzawa.j@pepabo.com> Date: Mon Jun 20 19:46:10 2016 +0900 Merge pull request #2 from Joe-noh/topic
  • 63.
    $ git revert06a1792
  • 64.
    $ git revert06a1792 error: Commit 06a1792… is a merge but no -m option was given. fatal: revert failed
  • 65.
    $ git revert06a1792 error: Commit 06a1792… is a merge but no -m option was given. fatal: revert failed -m
  • 67.
  • 70.
    $ git revert06a1792 -m 1 [topic 3d621f4] Revert "Merge pull request #2 from Joe-noh/topic" 1 file changed, 4 deletions(-)
  • 71.
    $ git revert06a1792 -m 1 [topic 3d621f4] Revert "Merge pull request #2 from Joe-noh/topic" 1 file changed, 4 deletions(-) $ git push origin revert-topic
  • 72.
    git rebase -i<commit hash> git cherry-pick <commit hash>
  • 73.
    master rebase master merge gitrevert <commit> git revert <merge-commit> -m 1