I accidentally push branch instead of master.
So is there any way to revert that push so that I can bring back the master code? I am supposed to execute this command to go another branch from master:
git checkout ProductBranch
but accidentally I executed this:
git push origin ProductBranch
"git push origin ProductBranch"
If ProductBranch
was previously pushed, you could force pushed its last state with:
git log ProductBranch
# make sure the history is the correct one, without your new commits
git push --force origin ProductBranch:ProductBranch
If ProductBranch
was never pushed before, then you might consider deleting it on the remote side:
git push --delete origin ProductBranch
Then, simply switch to master and push that:
git switch master
git push -u origin master
If you had committed to the wrong branch, you can fix those commits back to master before pushing .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.