3

Working on academic research I still haven't found a good git workflow for our project.

Setting: We have main project kept in branch master. When new idea emerges a new branch is created to support the research. Usually there is several parallel researches on the main project driven by different people.

When I am working on research branch R (it can take months, and many commits). Some of my commits are not directly connected with the research and are improving the project itself... I want to push these commits to master branch (they can be helpful for others).

How should I do this? Cherry-pick? It seems to me, that after lot of cherry-picks (from more people and different branches) it will be difficult to merge branch R with master at the end.

Maybe the better option is to switch to master before commit, make the commit, then switch back and pull updates from master. But this seems to be difficult, for three reasons:

  1. Switch to master is not easy because many files are not committed in conflict etc. (I need to use a stash somehow)
  2. Sometimes I realize later, that I should push older commit(s) from R to master.
  3. Sometimes I do not want other updates from master from someone else. They will be useful later but I don't have time to deal with them at the moment.

What is the proper way of doing it?

1 Answer 1

1

You could consider:

  • (on branch R) git rebase --interactive: in order to reorder the commits, with the one you want on master first, followed by the one specifics to R
  • (on branch master) merge SHA1 (the right SHA1 of the last commit you want on master)

But that will change the history of the R branch, which can be an issue of others have cloned it as well (you need to communicate clearly about that event, asking them to reset their R branch to the new one you have changed and push).

1
  • @Andrej no, reordering your commits is a common git practice, provided others who may have cloned that branch are aware of said reordering.
    – VonC
    May 12, 2013 at 9:20

Your Answer

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

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