Git create a new branch with the same name, will it be ported to the same remote?

In git, if I delete the local branch and create a new one with the same name. All commits from the new branch will be transferred to the same remote, as they have the same name. Is it correct?

+5
source share
1 answer

If you are doing git push origin branchname then yes that is correct.

The caveat is that you will have a different commit history from what happened, so you will need to force push your changes to click the button:

 git push origin branchname -f # or git push origin branchname --force 

If you do not, you will receive a message stating that your local branch is behind. Force pressing basically says "hey, origin, take my transaction history and deal with it."

+5
source

All Articles