git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Weird merge records

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 8, 2023, 17:17 UTC
Message-ID
<64592e8e848f2_8a9f294a3@chronos.notmuch>
In-Reply-To
<CAOvKW57WdwNoYXJyebMf-V4mQBz5CjvD=qhGxtht_2YKuygL1g@mail.gmail.com>
Dan Stromberg wrote:
Show 24 quoted lines
> On Mon, May 8, 2023 at 8:03 AM Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
> > > You seem to be implying that I shouldn't use 'git pull --rebase
> > > upstream "$branch"'.
> >
> > If you know what you are doing, then do whatever you want. `git pull --rebase
> > upstream $branch` is fine, if you know what that does.
> 
> I consider myself a git neophyte.  It's a large topic.
> 
> > I would just keep in mind that `git pull` wasn't meant to merge your changes to
> > upstream, it was meant to merge $branch to your integration branch.
> 
> I see.
> 
> > > If that's the case, what would you recommend?
> >
> > I would recommend `git fetch` + `git rebase` (or merge). If you are explicit
> > about what you want to do, surprises are minimized.
> 
> Might that look like:
>         git checkout "$branch"
>         git fetch upstream
>         git rebase "$branch"
With `git rebase` you specify the upstream branch you want to rebase to, so:
  git rebase upstream/master
This can be configured with the "upstream tracking branch" info, so:
  git rebase "$branch"@{upstream}
But this is the default of `git rebase`, so just:
  git rebase
>         git push origin "$branch"
If the branch already exists in the remote, you are probably going to need --force there.
Also, you don't need to checkout the branch, as `git rebase` can do that for you.
This is what I would do:
  git fetch upstream
  git rebase upstream/master $branch
  git push --force origin $branch

Hopefully in this scenario "upstream" is the upstream repository and "origin" is your personal fork.

-- 
Felipe Contreras
Previous: Dan StrombergNext: Dan Stromberg
Message 7 of 8 in “Weird merge records”
  1. Dan StrombergApr 28, 2023
  2. Thomas GuyotMay 6, 2023
  3. Felipe ContrerasMay 7, 2023
  4. Dan StrombergMay 8, 2023
  5. Felipe ContrerasMay 8, 2023
  6. Dan StrombergMay 8, 2023
  7. Felipe ContrerasMay 8, 2023
  8. Dan StrombergMay 8, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.