1

I already read this question but my question is different.

I am trying to rename a remote branch named feature/fix_unofficial_locales to features/fix-unofficial-locales

git checkout feature/fix_unofficial_locales
git pull
git branch -m features/fix-unofficial-locales
git push origin --delete feature/fix_unofficial_locales
git push origin -u features/fix-unofficial-locales

The error message now appears. enter image description here

feature/fix_unofficial_locales has never been in my local machine before, so I am checking it out for the first time. I have not made any commits so I don't understand why the tip of my current branch is behind...

Lun
  • 428
  • 4
  • 20
  • Don't push with the `-u` option. Can you try that? If that works, push again *with* the `-u` option to start tracking your branch. – mnestorov Oct 15 '20 at 08:11
  • You can try with `git push origin features/fix-unofficial-locales:features/fix-unofficial-locales`, then `git branch -u origin/features/fix-unofficial-locales` – Chuck Lu Oct 15 '20 at 09:01
  • Are you sure there isn't a `features/fix-unofficial-locales` branch on the origin already? If it is, then explain in more detail what exactly do you want (because it will not be a simple rename). – kajacx Oct 15 '20 at 09:15

1 Answers1

1

the error message feature/fix-unofficial-locales -> feature/fix-unofficial-locales (non-fast-forward) makes sense only if you rename your branch with a name of a remote branch already existing, with existing commits.

Try:

git fetch
git branch -u origin/features/fix-unofficial-locales features/fix-unofficial-locales
git pull
# resolve conflicts
git push

You can check this answer: How to push changes after rename branch on Bitbucket?

Tasnuva Leeya
  • 2,515
  • 1
  • 13
  • 21
  • Thanks. This worked for me. Although git pull shows a ton of changes. I never made any changes in this branch. Just renamed and repushed it... – Lun Oct 20 '20 at 09:36
  • Glad to hear. If this answer helps you do mark as accepted. – Tasnuva Leeya Oct 20 '20 at 17:51
  • how can i do that? – Lun Oct 21 '20 at 10:10
  • 1. Choose the answer that you believe is the best solution to your problem. 2. To mark an answer as accepted, click on the check mark beside the answer to toggle it from grayed out to filled in. – Tasnuva Leeya Oct 21 '20 at 11:35