[GRASS-dev] git: how to avoid bogus merge commits

Hi git gurus,

when I modify my local copy and do git commit + git push, I sometimes get an error:
“failed to push some refs”
and a hint:
“Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes (e.g., ‘git pull …’) before pushing again.”

OK, I do “git pull” and get confronted with a merge commit message.

After that, I do “git push” and commit a merge that does nothing.

Of course I could (should) do a “git pull” before a “git push”, but I think it is not uncommon that someone forgets the “git pull” before the “git push”. Therefore I would like to know how I can get rid of this bogus merge commit that changes nothing but spams the history, and burns Travis CI, e.g. [1, 2].

Thanks,

Markus M

[1] https://travis-ci.com/OSGeo/grass/builds/112790153
[2] https://travis-ci.com/OSGeo/grass/builds/112567602

On mercredi 22 mai 2019 21:30:58 CEST Markus Metz wrote:

Hi git gurus,

when I modify my local copy and do git commit + git push, I sometimes get
an error:
"failed to push some refs"
and a hint:
"Updates were rejected because the remote contains work that you do not
have locally. This is usually caused by another repository pushing to the
same ref. You may want to first integrate the remote changes (e.g., 'git
pull ...') before pushing again."

OK, I do "git pull" and get confronted with a merge commit message.

You may do

git fetch origin (assuming 'origin' point to OSGeo/grass)
git rebase origin/master
git push

this will rebase your local commit(s) on top of latest upstream repo

Even

--
Spatialys - Geospatial professional services
http://www.spatialys.com

On Wed, May 22, 2019 at 9:44 PM Even Rouault <even.rouault@spatialys.com> wrote:

On mercredi 22 mai 2019 21:30:58 CEST Markus Metz wrote:
> Hi git gurus,
>
> when I modify my local copy and do git commit + git push, I sometimes get
> an error:
> "failed to push some refs"
> and a hint:
> "Updates were rejected because the remote contains work that you do not
> have locally. This is usually caused by another repository pushing to the
> same ref. You may want to first integrate the remote changes (e.g., 'git
> pull ...') before pushing again."
>
> OK, I do "git pull" and get confronted with a merge commit message.

You may do

git fetch origin (assuming 'origin' point to OSGeo/grass)
git rebase origin/master
git push

this will rebase your local commit(s) on top of latest upstream repo

Thanks, Even,

I have updated the section
Keep your local source code up to date
https://trac.osgeo.org/grass/wiki/HowToGit#Keepyourlocalsourcecodeuptodate

best
markusN

Hi,

st 22. 5. 2019 v 21:44 odesílatel Even Rouault
<even.rouault@spatialys.com> napsal:

git fetch origin (assuming 'origin' point to OSGeo/grass)
git rebase origin/master

or possibly

git pull --rebase

could be used? Ma

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa

On Wed, May 22, 2019 at 3:31 PM Markus Metz <markus.metz.giswork@gmail.com> wrote:

Of course I could (should) do a “git pull” before a “git push”, but I think it is not uncommon that someone forgets the “git pull” before the “git push”.

It is not that executing push before pull causes problems. You simply need to do pull when the branch in remote repo changed.

You would need to do pull before commit. If you do commit before pull, rebasing (as suggested by Even) then redos the commits on top of updated branch as if you would do them after pull.

It is the “Git is not Subversion” song. As far as I understood, Subversion is similar to CVS. However, Git is very different than CVS: “Take Concurrent Versions System (CVS) as an example of what not to do; if in doubt, make the exact opposite decision.” [1]

[1] https://en.wikipedia.org/wiki/Git#History