As mentioned in the other example, you should use rebase instead of merge. But if you're working on a feature branch with your team then you'll run into the problem of pulling rewritten history. So the best way to work on a feature branch foo
is to locally create tracking branch foo
that you use only for pulling others' changes and create one more branch e.g. dev_foo
that you use only for pushing. Then use the basic workflow as if foo
was master
and dev_foo
your topic branch.
For example your history might look like this before submitting a change to review
x < dev_foo
/
a---b < foo
/
---s---t---u < master
To push commit x
to review and have it submitted to foo
use
git push origin dev_foo:refs/for/foo/dev_foo