変更がstageに乗ってない$ git status#On branch master# Changes not staged for commit:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: README.md#no changes added to commit (use "git add" and/or "git commit -a")
stash急ぎの変更をコミット大急ぎの変更エディタで以下のように変更してくださいHello, world!fooGit, a cool SCMgit add .git commit -m 'fix a fatal bug'
37.
stashに退避していた変更を戻す$ git stashpopAuto-merging README.md# On branch master# Changes not staged for commit:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: README.md#no changes added to commit (use "git add" and/or "git commit -a")Dropped refs/stash@{0} (f8b03350e0885238db913343722e5c345ea4aeb7)$ cat README.mdHello, world!fooGit, a cool SCMnow thinking.....
masterで変更する$ git checkoutmaster$ echo ‘bar’ >> README.md$ git add README.md$ git commit -m ‘add bar to the end’
47.
RB-1で変更する$ git checkoutRB-1$ echo ‘BAZ’ >> README.md$ git add README.md$ git commit -m ‘add BAZ to the end’
48.
マージする $ gitcheckout master $ git merge RB-1 Auto-merging README.md CONFLICT (content): Merge conflict in README.md Automatic merge failed; fix conflicts and then commit the result.CONFLICT(競合)しちゃった
49.
競合の確認CONFLICT(競合)しちゃった $ gitstatus # On branch master # Your branch is ahead of 'origin/master' by 1 commit. # # Unmerged paths: # (use "git add/rm <file>..." as appropriate to mark resolution) # # both modified: README.md # no changes added to commit (use "git add" and/or "git commit -a")
50.
競合を確認する$ cat README.mdHello,world!fooGit, a cool SCMnow thinking.....extra line<<<<<<< HEADbar=======BAZ>>>>>>> RB-1同じ位置(最終行)に違う変更を入れたため競合が発生しました
競合の修正を確認$ git diffdiff--cc README.mdindex fb2ada9,275ac2a..0000000--- a/README.md+++ b/README.md@@@ -3,4 -3,4 +3,8 @@@ fo Git, a cool SCM now thinking..... extra line- bar -BAZ++bar and BAZ
競合の修正をcommit $ gitcommit-m オプションを指定しないとエディタによるコメント入力が求められますが、デフォルトはこんな感じ Merge branch 'RB-1' Conflicts: README.md # # It looks like you may be committing a MERGE. # If this is not correct, please remove the file # .git/MERGE_HEAD # and try again. # # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # Your branch is ahead of 'origin/master' by 1 commit. # # Changes to be committed: # # modified: README.md #
A successful Gitbranching modelA successful Git branching model を翻訳しました http://keijinsonyaban.blogspot.com/2010/10/successful-git-branching- model.htmlA successful Git branching model を補助する git-flow を使ってみた http://d.hatena.ne.jp/Voluntas/20101223/1293111549