Re: Weird merge records

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 2023-04-28 11:34, Dan Stromberg wrote:
I suspect the merge records may be coming from this small bit of shell
script I've been using to pull from the master repo into my personal
repo:
     git fetch upstream
     git checkout "$branch"
     git config pull.rebase false
     git pull upstream "$branch"
     git push origin "$branch"

Does that snippet look responsible? If yes, how might I change it to
stop creating all those merge records? If no, any guesses what else
might be causing it?

It is, indeed. This is IMHO something the developers should do themselves, in particular the pull may fail on conflicts and you don't seem to stop when it does.

First of all, that line:

git config pull.rebase false


You shouldn't change the user's config - you can instead use command-line switches with git-pull to force the desired behavior. In this case (which is also the default if there is no pull.rebase config) it will merge with the remote (and that merge will be a fast-forward if you have no added commits).

If you have local commits that aren't on the tip of the remote branch (i.e. someone else committed to the branch) you really have only two options here, merge or rebase (there is a new preserve option I think that I'm not familiar with, seems like rebase but preserving local merges). Rebase is the way to avoid merge commits, but conflicts can be painful to resolve if you have many commits to push.

Also note the first fetch is redundant, pull already does a fetch.

So you could change your script to:

    git checkout "$branch"
    git pull --rebase upstream "$branch" || exit 1
    git push origin "$branch"


In the case the pull fails, you will be left with conflicts to resolve - the instructions should be printed on screen and also shown in git-status.

Regards,

--
Thomas




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux