Tried to git merge --ff-only, was rejected; then git merge did a fast-foward(?)

930 views Asked by At

Still learning GIT. Tried to sync my local repos with commit done on 'central repos' style remote repos. First step was fetch origin:

git fetch origin
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 1 (delta 0)
Unpacking objects: 100% (1/1), done.
From ssh://github.com/XXXXXX/ZZZZZZZZ
   bc2afff..3b3c8ee  master     -> origin/master

Then checked status and branch.

git status
# On branch master
# Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
#
nothing to commit (working directory clean)

git br
* master

Then tried to --ff-only.

git merge --ff-only origin master
fatal: Not possible to fast-forward, aborting.

Ok, so do a non-ff merge:

git merge origin master
Fast-forwarding to: origin
Already up-to-date with master
Merge made by the 'octopus' strategy.

Checked the commit:

git show 4cbd3
...snip...
Merge branch 'master', remote-tracking branch 'origin'

It appears that a non-ff merge was done. The output from the merge 'Fast-fowarding to: origin' is what is confusing -- what is it trying to tell me? What am I missing? Thanks!

1

There are 1 answers

0
Magnus Bäck On BEST ANSWER

Unlike e.g. git push, git merge does not take the name of a remote as an argument, so when you say git merge origin master you're actually saying "do an octopus merge from the 'origin' and 'master' branches". What you should've run is this:

git merge origin/master

Apparently you have a branch named "origin". Should it be there, or did you create it by mistake?

I'm not sure why you get inconsistent behavior between git merge origin master and git merge --ff-only origin master, but that doesn't really matter.