In our team we want to maintain a linear git history.
We have been running these commands:
user updates some files
git add .
git commit
git pull --ff-only
But we often see:
fatal: Not possible to fast-forward, aborting.
I am wondering if the git commands I am using could be improved? For example, by using git pull --rebase instead of git pull --ff-only ?
Steps to reproduce.
create 3 directories:
mkdir gitserver
mkdir gitclient1
mkdir gitcleint2
# server side
cd gitserver
git init --bare diverge.git
#client 1
cd gitclient1
git clone ../gitserver/diverge.git
cd diverge
<create index.html file with a few lines of text, save.>
git add .
git commit -m "first commit by user 1"
git push
#client 2
cd gitclient2
git clone ../gitserver/diverge.git
cd diverge
add a new line to index.html
git add .
git commit -m "changed line made by user 2"
git push
# back to client 1
$ git pull --ff-only
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 D:/projects/git/git_diverge_test/gitclient1/../gitserver/diverge
7208075..ce21832 master -> origin/master
fatal: Not possible to fast-forward, aborting.
Why do I get the fatal message?
Shouldn't git have been able to pull down the commit on top of the existing commit?
And if I run gitk --all I see that master is on a different 'branch' of the tree from remotes/origin/master.
One approach that works to an extent is to use:
git pull --rebase
<fixup any issues>
git add .
git rebase --continue
Is git pull --rebase more dangerous in any way?