1

I'm using Continuous Intergration with PHPCI and stepped off using multiple branches. Currently we're happy with using simply the master branch to commit (and directly build) all changes.

When another programmer pushes something, and I have to commit my things, usually the following happens:

git commit -a -m 'fixed some stuff'
git pull origin master # -- this creates a merge, even when there's no conflicts
git push origin master

This then creates 2 new commits. One of those is completely useless, as it simply restates what the other developer already did! This slows down the CI and is very annoying. I'm fine if there's a commit on a conflict (although there's no real reason to build it separately), but I think there must be a way around these empty merges.. the files didn't actually change aside from the new stuff that was committed.

Anyone know if there's another way to merge that will not create a merge commit?

2 Answers 2

5

Force Fast-Forwards

To avoid merge commits, you need to enforce fast-forwards whenever possible. Both git-merge and git-pull support the --ff-only flag. The man pages say:

   --ff-only
       Refuse to merge and exit with a non-zero status unless the current
       HEAD is already up-to-date or the merge can be resolved as a
       fast-forward.

This flag should help you cleanly merge commits without conflicts that can be resolved as fast-forwards, while still allowing you to handle conflicts in the usual ways.

Sign up to request clarification or add additional context in comments.

Comments

-1

git pull --rebase origin master

1 Comment

Although the code is appreciated, it should always have an accompanying explanation. This doesn't have to be long, but it is expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.