On git, if I delete the local branch and create a new one with the same name. All the commits from the new branch will be pushed to the same remote since they have the same name. Is it correct?
If you do git push origin branchname
then yes that's correct.
The caveat is that you will have a different commit history from what origin has, so you will need to force push your changes for the push to work:
git push origin branchname -f
# or
git push origin branchname --force
If you don't, you'll get an error telling you that your local branch is behind origin. Force pushing basically says "hey origin, take my commit history and deal with it."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With