Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git create new branch with same name, will it be pushed to the same remote?

Tags:

git

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?

like image 365
xin buxu1 Avatar asked Apr 30 '15 02:04

xin buxu1


1 Answers

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."

like image 138
scrowler Avatar answered Oct 25 '22 10:10

scrowler