Git - Branching Out: Multiple Trains of Thought - merge, conflict
Head First Git: A Learner’s Guide to Understanding Git from the Inside Out、 Raju Gandhi(著)、 O’Reilly Mediaの Chapter 2.(Branching Out: Multiple Trains of Thought)、SHARPEN YOUR PENCIl(203/715)の解答を求めてみる。
入出力結果(Terminal, Zsh)
% mkdir loving-git
% cd loving-git
% git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
hint:
hint: Disable this message with "git config set advice.defaultBranchName false"
Initialized empty Git repository in /Users/.../loving-git/.git/
% code tribute.md
% git add tribute.md
% git commit -m 'A'
[master (root-commit) 8cd2c9a] A
1 file changed, 1 insertion(+)
create mode 100644 tribute.md
% git branch improvisation
% git switch
fatal: missing branch or commit argument
% git switch improvisation
Switched to branch 'improvisation'
% ls
tribute.md
% pwd
/Users/.../loving-git
% git add tribute.md
% git commit -m 'B'
[improvisation 60ad401] B
1 file changed, 6 insertions(+), 1 deletion(-)
% git switch master
Switched to branch 'master'
% git add tribute.md
% git commit -m 'C'
[master af9559a] C
1 file changed, 6 insertions(+), 1 deletion(-)
% git status
On branch master
nothing to commit, working tree clean
% git branch
improvisation
* master
% git merge improvisation
Auto-merging tribute.md
CONFLICT (content): Merge conflict in tribute.md
Automatic merge failed; fix conflicts and then commit the result.
% git log --all --graph --oneline
* af9559a (HEAD -> master) C
| * 60ad401 (improvisation) B
|/
* 8cd2c9a A
% git merge improvisation
error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
% git add tribute.md
% git commit -m 'D'
[master d47d1bc] D
% git log --all --graph --oneline
* d47d1bc (HEAD -> master) D
|\
| * 60ad401 (improvisation) B
* | af9559a C
|/
* 8cd2c9a A
%
commit graph