What are the differences between git remote prune, git prune, git fetch --prune, etc

前端 未结 4 1996
野趣味
野趣味 2020-11-27 09:06

My situation is this... someone working on the same repo has deleted a branch from his local & remote repo...

Most people who have asked about this kind of probl

4条回答
  •  不知归路
    2020-11-27 09:19

    git remote prune and git fetch --prune do the same thing: deleting the refs to the branches that don't exist on the remote, as you said. The second command connects to the remote and fetches its current branches before pruning.

    However it doesn't touch the local branches you have checked out, that you can simply delete with

    git branch -d  random_branch_I_want_deleted
    

    Replace -d by -D if the branch is not merged elsewhere

    git prune does something different, it purges unreachable objects, those commits that aren't reachable in any branch or tag, and thus not needed anymore.

提交回复
热议问题