I have a git repository that uses GitFlow (i.e., it has master
, develop
, release-*
, and feature-*
branches). The collaborators have not been using explicit merges (i.e., git merge --no-ff
), however, and so e.g. git log --first-parent
does not provide a simple roll-up of the merge history to date.
Moving forward, the collaborators will be using explicit merges. Before they do, however, I'd like to make sure that the history is "clean", so that no prior history is displayed when calling git log --first-parent
. But, obviously, I want to maintain the actual commit history when calling an unfiltered git log
.
My inclination is to do the following:
$ git checkout develop
$ git checkout --orphan CleanSlate
$ git rm . -r -f
$ git commit --allow-empty -m "Establish a clean slate for the develop branch"
$ git merge --no-ff --allow-unrelated-histories develop -m "Introduce all legacy files"
$ git checkout develop
$ git merge CleanSlate
Basically, the idea is that we'll:
- Establish a fresh (
--orphan
) branch with no prior history - (Optional) Remove all files from the working tree so that we're not recommitting them
- Establish an initial commit so that we have something to merge into
- Perform an explicit merge (i.e.,
--no-ff
) from thedevelop
branch, acknowledging the unrelated histories - Fast forward
develop
to the explicit merge we just performed so that represents the history
My Question(s): Are there consequences to this approach that I should be aware of before applying it to a production environment? Are there alternative or simpler approaches that are preferable for accomplishing this type of scenario?
(In testing, this seems to achieve my objective with no adverse impact on existing branches or workflow. But, with git, I'm always wary of what I don't know I don't know.)