On Mon, Feb 06, 2023 at 03:13:55PM +0100, Uwe Brauer wrote:

> I just pulled from a repository in which a user created a new branch (and he
> should not) but interrupted the graph. So it looks using 
> git log --since=2years --graph --color=always --all --decorate --pretty=short 
> | git name-rev --annotate-stdin | less -R
> As follows: the graph starts like 
> * commit 962fe4d0665264e16cca975d0d3a0f887a91ee99 (main) (HEAD -> main, 
> origin/main, origin/HEAD)
> | Author: XXX
> |
> |     correciĆ³n funciĆ³n plot
> The branch finished like this
> And branch finished like 
> * commit a6ca1af6e8db2e96153a918c9bb9b40f02ccd787 (main~11)
> | Author: XXX
> |
> |     funcion mieuler
> |
> * commit 03ef0f5985d30b598d808b68e1ec85a0bb405d71 (main~12)
>   Author: Hugo Del Castillo Mola <hdelc...@ucm.es>
>       Limpiar commits
> * commit d81bd81b396096fc02aac874a75bccd656183a99 (remotes/origin/default) 
> (origin/default)
> | Author: XXX
> |
> |     Quitar plot mirk4
> |
> Now I don't want him to use a branch called main.
> (I am using mercurial and the hg-git plugin, so it is much easier for me
> if the main branch is called default, I omit the reasons.
> Now I cannot merge his main branch into default, well I can but there
> are so many merge conflicts, that I refuse to solve them. So what is the
> best way to solve this
>     1. Merge and then reset git to his change set?
>     2. Rename his branch again to default (but I am afraid that git gets
>        confused with the local branch called default and the one on
>        origin.) 
> So any suggestion would be very much appreciated.

I'm not sure I follow as I failed to parse what does "interrupted the graph"
stands for, but let me have a guess.

To me, looks like you the "main" branch completely contains the history
of the "default" branch - that is, basically you have

           ^                   ^
           default's tip       main's tip

It's easy to check that by running

  git branch -r --contains default

if origin/main is listed, that's it.

If so, a mere

  git push origin main:default

would make sure the branch "default" in the remote repo now points at the same
commit as "main".

If this sounds too hardcore, do

  git checkout default
  git merge --ff-only main
  git push origin default

That "--ff-only" instructs `git merge` to perform a so-called "fast-forward"
merge which is not really a merge but rather repositioning of the branch
pointer. Basically, if "main" is contained in "default" would make Git to
merge FF merge by default, so "--ff-only" is merely a reassurement check: the
command will fail if the merge would not be fast-forward.

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 

Reply via email to