如果我们某次修改了某些内容,并且已经commit到本地仓库,而且已经push到远程仓库了?这种情况下,我们想把本地和远程仓库都回退到某个版本,该怎么做呢?
前面讲到的git reset只是在本地仓库中回退版本,而远程仓库的版本不会变化,这样,即时本地reset了,但如果再git pull,那么,远程仓库的内容又会和本地之前版本的内容进行merge,这并不是我们想要的东西,这时可以用 以下 方法来解决这个问题:
#删除远程的xxx分支
git push origin :xxx
===============================
Here’s a solution if you ever get the following error when trying to delete the master branch in a remote repository:
<span style="background-color: rgb(255, 255, 102);">remote: error:</span> By default, deleting <span style="color:white; background-color:#886800">the current branch</span> is denied, because <span style="color:white; background-color:#886800">the</span> next
<span style="background-color: rgb(255, 255, 102);">remote: error:</span> 'git clone' won't result in any file checked out, causing confusion.
<span style="background-color: rgb(255, 255, 102);">remote: error:
remote: error:</span> You can set 'receive.denyDeleteCurrent' configuration variable <span style="color:white; background-color:#880000">to
remote: error:</span> 'warn' or 'ignore' in <span style="color:white; background-color:#886800">the</span> remote repository <span style="color:white; background-color:#880000">to</span> allow deleting <span style="color:white; background-color:#886800">the
remote: error: current branch</span>, with or without a warning message.
<span style="background-color: rgb(255, 255, 102);">remote: error:
remote: error: To</span> squelch this message, you can set it <span style="color:white; background-color:#880000">to</span> 'refuse'.
<span style="background-color: rgb(255, 255, 102);">remote: error: refusing to delete the current branch</span>: refs/heads/master
<span style="color:white; background-color:#880000">To</span> /somewhere/in/<span style="color:white; background-color:#886800">the</span>/cloud/repo.git
! [remote rejected] master (deletion of <span style="color:white; background-color:#886800">the current branch</span> prohibited)
<span style="background-color: rgb(153, 255, 153);">error:</span> failed <span style="color:white; background-color:#880000">to</span> push some refs <span style="color:white; background-color:#880000">to</span> '/somewhere/in/<span style="color:white; background-color:#886800">the</span>/cloud/repo.git'
The reason you’re seeingthe error is that HEAD onthe remote repository by default contains something like this (see also line 9 inthe error message above):
ref: refs/heads/master
If you have access to the remote repository, simply modifythe HEAD file to point to a differentbranch and then you’ll be ableto delete the remote masterbranch. There are some significant implicationsto modifying the remote HEAD, especially if other users are tracking thatbranch, so make sure you know what you’re doing if you chooseto point it to some other arbitrary branch.