Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have the following problem on one of our servers: I want a user that pulls from a Git repo on a regular basis (using a cronjob), but only doing fast-forward pulls (the content on the server changes sometimes, too). With modern Git (1.6.6 and newer), I can simply do

git pull --ff-only origin master

but since I only have 1.6.0.2 installed, I can't do that. I thought I could work around it by doing

git config merge.ff only
git pull origin master

but as it turned out, that did not work (no error, it still does merges though). Any ideas how I can solve this?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I've found a solution to this by manually checking if the current branch (master) is actually a descendant of the branch to be merged (origin/master):

git fetch origin
if [ $(git branch --contains master -a | grep origin/master) ]
then
    git merge origin/master
else
    echo "No fast-forward, aborting merge"
fi
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.