[GRASS-dev] Renaming master branch to main branch

Vaclav Petras wenzeslaus at gmail.com
Fri Sep 10 10:51:40 PDT 2021


On Fri, Sep 10, 2021 at 1:16 PM Markus Metz <markus.metz.giswork at gmail.com>
wrote:

> ...
> $ git checkout raster_tempdir
> $ git rebase main
>
> Successfully rebased and updated refs/heads/raster_tempdir.
>
> $ git status
> On branch raster_tempdir
> Your branch and 'metzm/raster_tempdir' have diverged,
> and have 48 and 7 different commits each, respectively.
>   (use "git pull" to merge the remote branch into yours)
>
> $ git push metzm raster_tempdir
> ! [rejected]            raster_tempdir -> raster_tempdir (non-fast-forward)
> error: failed to push some refs to 'github.com:metzm/grass.git'
> hint: Updates were rejected because the tip of your current branch is
> behind
> hint: its remote counterpart. Integrate the remote changes (e.g.
> hint: 'git pull ...') before pushing again.
> hint: See the 'Note about fast-forwards' in 'git push --help' for details.
>

This is how it is supposed to behave when you do `git rebase`. Rebasing
re-applies the changes you made in raster_tempdir one by one on top of your
local main. This creates different commits in the sense that the commit
hashes are different. This causes the "have diverged" part. 48 on the local
raster_tmpdir is your 7 commits plus 41 commits which happened in the main
branch since you created raster_tempdir. 7 commits on metzm/raster_tempdir
is the original commits you made which have the original, different hash,
so Git considers them to be different.

Force push with `git push -f metzm raster_tempdir` is appropriate here. You
will replace whatever is in the remote branch by your newly updated
(rebased) local branch content.

We are currently merging all PRs using the "Squash and merge" feature, this
reduces the commit which will go to the main branch to only the actual
changes taking care of the merge commits. So, you can use git merge or git
rebase on your branches.

I still prefer rebase most of the time because it is easier to review
commits in the PR (since there are no merge commits). Some people also use
rebase to reduce the commits on a branch to one, but I think that's usually
not helpful for review. However, merge does not require the strange force
pushing and it works better in case of conflicts because you are simply
merging the latest state, not each commit on your branch which is the case
with rebase.

As far as I can tell, the master-main rename should not have any influence
on this. And yes, the message from `git push` is not applicable here.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20210910/e52dce0e/attachment.html>


More information about the grass-dev mailing list