Repository surgery is complete

Fred Wright fw at fwright.net
Mon Mar 20 19:13:03 UTC 2017



On Mon, 20 Mar 2017, Jason Azze wrote:

> On Mon, Mar 6, 2017 at 3:41 PM, Eric S. Raymond <esr at thyrsus.com> wrote:
> > The NTPsec repo is open for commits again.
> >
> [snip]
> >
> > If you have any difficulties with the alterered repo, please report them.
>
> I created a GitLab fork of the project before the surgery, which I
> used for generating merge requests.
>
> I just attempted to set up repository mirroring with the main project
> repo so that my fork stays up-to-date.
>
> The sync failed with the following GitLab error in the web UI:
>
> "The default branch (master) has diverged from its upstream
> counterpart and could not be updated automatically."
>
> I think this is expected behavior after the surgery. I'm just leaving
> a note here on devel for the record. It will probably be necessary to
> delete my fork and create a new one.

Not at all.  I can't speak to whether there's a way to deal with this in
the WebGUI, but it can certainly be done with local git tools.

First of all, keep a copy of the old master branch before force-updating
the local master (in case you need to refer to the old one):

$ git checkout -b old-master master
$ git fetch upstream +master:master

Now you have an updated master, but still have the old one.

Next, try rebasing any local development branches to the new master, but
with interactive rebase in case git doesn't figure out the update
properly:

$ git rebase -i master dev-branch

When I did that here, git miraculously figured out the changes correctly
(with only my local changes listed), so I just exited the interactive
rebase edit and let it finish.  I'd expected it to come up with a huge
list of changes going all the way back to the last common commit, but it
was smarter than that.

If the rebase hadn't worked properly, I could have used cherry-pick
instead:

$ git branch -m dev-branch old-dev-branch
$ git checkout -b dev-branch master
$ git cherry-pick old-master...old-dev-branch

If you have any local tags, they'll need to be updated as well (not shown
here).

Once everything is updated locally, each branch can be force-pushed to the
fork:

$ git push -f origin master
$ git push -f origin dev-branch
$ ...

Then clean up:

$ git branch -D old-master
$ git branch -D old-dev-branch
$ ...

$ git gc

Fred Wright


More information about the devel mailing list