Git push with or without force

Removing a remote branch is done with:

git push origin :master

      

If the local value is behind the remote control, this must be done with:

git push --force origin :master

      

But what does it mean to force deletion, such as the master that the local master points to? You will not delete what the wizard points to on the remote.

+3


source to share


1 answer


:branch

refspec is the syntax for pushing the delete of a branch , also written as:

git push origin --delete <branchName>

      

This should not be confused with git push :

, where " :

" stands for "matching branch"
.

--force

used for the case where the local branch has a different history than its remote instance ( upstream branch ).



For example, if you rebase master

, its history will change and you need -force to push it.


You will not delete what the wizard points to on the remote.

No, you will delete the branch itself (in the remote repo), not commit that branch in the remote repo.
if these commits no longer reference any branch, they will become "invisible" (soft deletion), but will still be available through git reflog

runs on that remote repo (on the remote server).

+3


source







All Articles