简体   繁体   English

无论有没有力量都可以推动

[英]Git push with or without force

Deleting a remote branch is done with: 删除远程分支是通过以下方式完成的:

git push origin :master

If the local is behind the remote it needs to be done with: 如果本地在遥控器后面,则需要完成:

git push --force origin :master

But what does it mean to force a delete of eg master based on where the local master is pointing at? 但是根据本地主人指向的位置强制删除例如master是什么意思? You will not be deleting where master is pointing to in the remote. 您不会删除主控制器在遥控器中指向的位置。

The :branch refspec is the syntax for pushing a branch deletion , also written as: :branch refspec是推送分支删除的语法,也写成:

git push origin --delete <branchName>

This isn't to be mixed up with git push : , where the ' : ' stand for "matching branch" . 这不能与git push :混淆, 其中' : '代表“匹配分支”

The --force is used for the case where a local branch has a different history than its remote counterpart ( upstream branch ). --force用于本地分支具有与其远程对应( 上游分支 )不同的历史的情况。

For example, if you rebase master , its history would change and you would need --force to push it. 例如,如果你变基 master ,它的历史会改变,你将需要--force来推动它。


You will not be deleting where master is pointing to in the remote. 您不会删除主控制器在遥控器中指向的位置。

No, you will be deleting the branch itself (in the remote repo), not the commits of that branch in the remote repo. 不,您将删除分支本身(在远程仓库中),而不是远程仓库中该分支的提交。
if those commits are no longer referenced by any branch, they will become "invisible" (soft delete), but will still be accessible through a git reflog executed in that remote repo (on the remote server). 如果这些提交不再被任何分支引用,它们将变为“不可见”(软删除),但仍可通过在该远程服务器中执行的git reflog访问(在远程服务器上)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM