The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Graeme Ludwig (6) [Avatar] Offline
Hi. I'm currently working through chapter 14, specifically the clean merge, section 14.3.1.

When I do the git pull from math.carol, I get completely different behaviour from the two possiblities given in the text i.e.

Step 1: Making change in math.carol and committing locally:

$ cd math.carol
$ echo "Small change 2" >> another_rename
$ git commit -a -m "Small change 2 from carol"
$ git log --decorate --all --oneline

55b1a16 (HEAD -> master) Small change 2 from carol
e9c0bf0 (origin/master, origin/HEAD) Another tiny change
384cdd8 Small change

Step 2: Making change in math.bill, committing and pushing:

$ cd ../math.bill
$ echo "Small change 2" >> another_rename
$ git commit -a -m "Small change 2 from bill"
$ git push

Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 294 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To /Users/ludwiggj/code/gitMonthLunches/chapter14_take2/math.git
e9c0bf0..39933ca master -> master

$ git log --decorate --all --oneline

39933ca (HEAD -> master, origin/master, origin/HEAD) Small change 2 from bill
e9c0bf0 Another tiny change
384cdd8 Small change

Step 3: Pulling from math.carol:

$ cd ../math.carol

$ git pull

remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /Users/ludwiggj/code/gitMonthLunches/chapter14_take2/math
e9c0bf0..39933ca master -> origin/master
First, rewinding head to replay your work on top of it...

$ git lolg
* 39933ca (HEAD -> master, origin/master, origin/HEAD) Graeme Ludwig [2016-05-03] Small change 2 from bill
* e9c0bf0 Graeme Ludwig [2016-05-03] Another tiny change
* 384cdd8 Graeme Ludwig [2016-05-03] Small change

So instead of either merging the pull and adding an automatic commit message, or throwing me into an editor to complete a commit message, instead the commit "55b1a16 (HEAD -> master) Small change 2 from carol" in math.carol has completely disappeared, and been replaced with the 39933ca "Small change 2 from bill" commit.

I understand the fact that no changes have actually been lost from the underlying files (since both commits in the two different repos were the same change), but am confused, as the commit history that results in math.carol is completely different to that stated in the text.

I'm running git 2.7.0 on a MacBook Pro running El Capitain (10.11.4). I've attached a file gitconfig.txt file showing the result of running "git config -l" in the math.carol directory.

I'd appreciate any explanations as to what is going on.

(A secondary comment: assuming I can get my example above to behave as per the book text, the text in section 14.3 describes that you might get a clean merge with automatic commit or nonautomatic commit, but doesn't explain what controls which of these options is chosen?)
Graeme Ludwig (6) [Avatar] Offline
I figured this out on the bus this morning. The penny dropped when I read the following from the git help for the pull command:

"More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. With --rebase, it runs git rebase instead of git merge."

My git config contained the following setting:


which I'd previously set, and forgotten about. This setting caused git pull to rebase the changes rather than merge them. Once I'd removed this setting then the book examples worked as I expected.

I also found the options that control whether a clean merge occurs with an automatic commit or nonautomatic commit i.e. git pull --edit | --no-edit, still think that a pointer to this could be added to the book text.
rickumali (134) [Avatar] Offline
Thanks for posting this, Graeme!

Your feedback on adding some text regarding git pull's --edit and --no-edit switches is valid. I'm glad you posted such detail in this forum post, as I believe future readers can benefit from it here.

Thank you again!