I've just inherited a project which was maintained using Git. At one point, the code was deployed onto 3 separate systems and each system maintained their own decentralised Git respository.
Each of the 3 systems extended the original base system in 3 different directions. None of the 3 systems have been synchronised against each other. Some changes are on master branch, others are on new branches.
How can I bring the 3 different sources together so that I can:
Here’s a quick tutorial on getting out of a git mess. The first goal is to make both the local computer’s and our Github fork’s master branches look like the upstream, the repository that was forked, master branch, without losing changes already made. Checkout the master branch.
A good pull request is done off a feature branch and includes 3 files: the README change, a personal page and a picture named the same way as the personal page file. Here’s a good one from one of our TAs, minus the feature branch. Since most students use git for the very first time they often make some kind of mess.
Since most students use git for the very first time they often make some kind of mess. Everyone successfully forks the repository, clones it locally, makes changes (usually on master ), commits and pushes, but that’s where the issues begin. They try to update from the upstream repository, squash commits, rebase things and make a huge mess.
When first introduced to Git, it's typical for developers to feel uncomfortable with the process. You might feel uncertainty when encountering the Git commit message, unsure how to properly summarize the changes you've made and why you've made them. But the earlier in your career you can develop good committing habits, the better.
I would probably start by pushing all the repositories to separate branches in a central repository, from which I can rebase, merge etc between branches easily.
A good visualization tool such as git-age, gitnub, gitx, giggle can work wonders, but your task will probably be rather tedious unless you can find the branching points. If there are similar patches applied to all branches you can use (interactive) rebase to reorder your commits such that they are in the same order. Then you can start 'zipping up' your branches, moving the branch-point upwards by putting commits into master. A nice description on how to reorder commits using rebase can be found here.
Chances are the actions you need to take are described in the links provided by the Git Howto Index. A good cheat sheet is always nice to have within reach. Also, I suspect the followup to Eric Sinks post "DVCS and DAGs, Part 1" will contain something useful (It didn't, but was an interesting read nontheless).
Additional good-to-have links are: Git Magic, Git Ready and SourceMage Git Guide
I hope all the repos had good commit messages that tell you the purpose of each patch, it's that or code review :)
As for how to maintain customizations we've had luck with the following:
We started by separating (or keeping separate) the customized code from the generic code. Then we've tried two approaches; both which worked fine:
After the first deployment and seeing that the second was a fact we spent some time trying to foresee future customization/cutting points to reduce duplication across the customized repos (alt. 1, which is the approach we currently use) and in the base/core repo.
And yes, we do try to refactor mercilessly whenever we notice the core/customization split slipping :)
OK. After a big of a slog, I've managed to do it. For anybody else embarking on a similar task, it will involve a lot of:
git rebase
commands and when things got screwed up:
git reflog
followed by
git reset --hard HEAD@{ref}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With