branch swap didn't get synchronized to remote

I made a branch meant to be experimental and alternative to master so did

git branch M

after it's been worked, it turns out to be better, so did swap:

1
2
git branch  -m master old 
git branch  -m M master  


but when ready, did push, suddenly
1
2
3
4
5
6
fatal: The upstream branch of your current branch does not match 
the name of your current branch.  To push to the upstream branch 
on the remote, use 
 
    git push origin HEAD:M 
...


It didn't get synchronized into remote git.
How's the correct one, will anyone point out the important missing/subtle step ?

Last edited on
> after it's been worked, it turns out to be better, so did swap:
You should have merged M back to master.

Not done some 'clever' attempt at trying to rename the branch.

A branch is it's entire history, not some label at the end of an anonymous list of commits.
That's why your upstream is complaining.

Before doing anything, make a tarball/ZIP of your entire work tree and .git directory.

If you've done nothing else in the meantime, then perhaps

1. Undo the renaming mess
git branch -m master M
git branch -m old master


2. Do a proper merge back to master
git checkout master
git merge M

https://git-scm.com/docs/git-merge


If that doesn't work, then you need to re-clone a fresh remote, and copy your changes in manually.

https://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows
https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows
Last edited on
Well done!
Topic archived. No new replies allowed.