zoukankan      html  css  js  c++  java
  • 回退 服务器 上的 git 仓库 & 删除 服务器上的 git 分支

    如果我们某次修改了某些内容,并且已经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:

    remote: error: By default, deleting the current branch is denied, because the next
    remote: error: 'git clone' won't result in any file checked out, causing confusion.
    remote: error: 
    remote: error: You can set 'receive.denyDeleteCurrent' configuration variable to
    remote: error: 'warn' or 'ignore' in the remote repository to allow deleting the
    remote: error: current branch, with or without a warning message.
    remote: error: 
    remote: error: To squelch this message, you can set it to 'refuse'.
    remote: error: refusing to delete the current branch: refs/heads/master
    To /somewhere/in/the/cloud/repo.git
     ! [remote rejected] master (deletion of the current branch prohibited)
    error: failed to push some refs to '/somewhere/in/the/cloud/repo.git'
    

    The reason you’re seeing the error is that HEAD on the remote repository by default contains something like this (see also line 9 in the error message above):

    ref: refs/heads/master
    

    If you have access to the remote repository, simply modify the HEAD file to point to a different branch and then you’ll be able to delete the remote master branch. There are some significant implications to modifying the remote HEAD, especially if other users are tracking that branch, so make sure you know what you’re doing if you choose to point it to some other arbitrary branch.






  • 相关阅读:
    window.open的小技巧分享
    2019实习笔试编程题刷题心得
    剑指offer——面试题32.1:分行从上到下打印二叉树
    剑指offer——面试题32:从上到下打印二叉树
    剑指offer——面试题30:包含min函数的栈
    剑指offer——面试题29:顺时针打印矩阵
    字节跳动2018校招测试开发方向(第二批)
    剑指offer——面试题27:二叉树的镜像
    剑指offer——二叉树
    剑指offer——面试题26:判断二叉树B是否为二叉树A的子结构
  • 原文地址:https://www.cnblogs.com/liulaolaiu/p/11744787.html
Copyright © 2011-2022 走看看