Previous SVN workflow
- svn cp $PATH/trunk $REPO/branches/feature_xxx
- git checkout $REPO/branches/feature_xxx
- developers worked on working copy of branch, ocasionally merging back with master and before marking the branch as "ready to merge"
- when the feature was ready, owner did
svn merge --reintegrate $REPO/branches/feature_xxx
, run complete test suite and if everything ok then ```svn commit -m "merged feature_xxx" - when a release was ready
svn cp $REPO/trunk $REPO/tags/vX.Y.Z
and released that tag.
The svn trunk history looked nice and clean:
version 4.5.4
feature_xxx
bugfix_yyy
version 4.5.3
feature_zzz
version 4.5.3
bugfix_aaa
We don't care about internal commits, but if we wanted we can use svn log -g
that will expand the merged commits into it's internal ones (was useful one or two times).
Now we switched to Git and Gitlab, mosty because of it's feature to comment on merge requests and diffs. But we are struggling to get the same clean workflow, this was more or less what happened:
Strategy 1: attemped to merge a feature branch (via git or Gitlab "Merge" button)
Ok.. this is easy! Ehh wait WTF are those previous commits that are polluting my master's log.
Resolution: no way, this is a mess.
Strategy 2: learned about git merge --squash
Ok.. this is what we want.. now we have a nice history, but we have to do it from command line because Gitlab CE doesnt' allows it from GUI (https://gitlab.com/gitlab-org/gitlab-ce/issues/34591). No big deal, we do it from command line.. oh wait, why hasn't Gitlab detected we closed the merge request..!? that was happening automatically before.
So, we learned there is no way for it to detect the branch was merged.. sure there is another way (eg. closing with a commit message). Ups not implemented yet: https://gitlab.com/gitlab-org/gitlab-ce/issues/13268.
Resolution: the history looks nice, BUT we need to manually close the merge requests so we loose the ability to track which ones we closed as "not intented to do" from "closed but merged manually via squash". Sure there must be a better way..
Strategy 3: learned about git rebase..
Ok, so when a branch is finished we do git rebase origin/master
and then git rebase -i XXXXX
where XXXX is the oldest common ancestor and we sqash all commits with a message "implemented feature_xxx". And then we simply merge with master via cmd line or GUI.
Resolution: now gitlab detects which merge requests are merged.. good. But rebasing can be a PITA for long branches and a loss of time sometimes, so when things get hairy we simply go back to merge --squash
. Also the log is not so clean becaouse we have for every branch the implemented feature_xxx and then merged feature_xxx commits.. it's not as bad as simply merging but still is noise.
Conclusion
So now we are using the last strategy.. trying to git rebase
most of the time but reverting to git merge --squash
when things get hairy. But to be honest we are not 100% happy, the SVN workflow was clean and simpler.
Are we missing something? Thanks