0

I use git in a Linux system and a mac. In my Linux machine, when I have no local commits and I just git pull from origin, it just forwards to the latest commit in mainline. However, when I do the same in my mac, it always creates a merge commit regardless of whether I have local commit or not.E.g.:

alias gln='git log --graph --pretty=format:'\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit --date=relative -n'

Original state (In Linux & Mac):

gln 2

* 6b05c11 - (HEAD -> mainline, origin/mainline, origin/HEAD) Original HEAD commit message (1 year, 4 months ago) <User1>
* f8cf2ee - Very old commit message (1 year, 8 months ago) <User1>

Git pull in Linux (just forwards, no merge commit)

gpl
gln 4

* ef1d887 - (origin/mainline, origin/HEAD) Remote commit message 2 (9 weeks ago) <User2>
* 190df9c - Remote commit message 1 (9 weeks ago) <User2>
* 6b05c11 - Original HEAD commit message (1 year, 4 months ago) <User1>
* f8cf2ee - Very old commit message (1 year, 8 months ago) <User1>

Git pull in Mac, it pulls & creates a merge commit

gpl
gln 5

* 254b0c7 - (HEAD -> mainline) Merge branch 'mainline' of ssh:......../MyPackage into mainline (7 seconds ago) <Myself>
|\  
| * ef1d887 - (origin/mainline, origin/HEAD) Remote commit message 2 (9 weeks ago) <User2>
| * 190df9c - Remote commit message 1 (9 weeks ago) <User2>
|/  
* 6b05c11 - Original HEAD commit message (1 year, 4 months ago) <User1>
* f8cf2ee - Very old commit message (1 year, 8 months ago) <User1>

Now I always have to do 'git rebase -i' in my Mac after every pull to get rid of the merge commit (which just shows a noop message and rebases right away).

[Question] Is there any configuration I can change to make my mac git behaviour similar to my linux git behaviour?

aalosious
  • 578
  • 6
  • 11
  • what is in the `gpl` alias? Do you have `--no-ff` or `merge.ff` in your config? – drRobertz Jun 12 '18 at 09:08
  • Rebasing a merge commit does not necessarily work the way you think it does. Are you certain that your local branch can be fast forwarded on the Mac (and other machines)? I've never actually seen this, having used Git for many years. – Tim Biegeleisen Jun 12 '18 at 09:08
  • 1
    Maybe related: https://stackoverflow.com/questions/9069061/what-is-the-difference-between-git-merge-and-git-merge-no-ff and https://stackoverflow.com/questions/2500296/can-i-make-fast-forwarding-be-off-by-default-in-git – drRobertz Jun 12 '18 at 09:11

1 Answers1

0

Found the issue & got the fix thanks to Can I make fast forwarding be off by default in git? & drRobertz comment.

I had added the below lines in my Mac .gitconfig some time ago (don't know what for). That was causing the issue.

[branch "mainline"]
    mergeoptions = --no-ff

Having removed it, my git pulls are working without adding a merge commit (when I have no local changes).

aalosious
  • 578
  • 6
  • 11