The branch on the git remote has been deleted, and the branch still exists in its own repository

background:

Recently, the company's project has been migrated from svn to git. During the use, I found that the remote branches created by others have been deleted after the code is merged, but the snapshots of his branches still exist in my local repository. I have pulled the code of the remote branch, but I still cannot delete the snapshot in my warehouse.

Problem: The branches on the remote warehouse have been deleted. After the code is pulled, these branches are still kept in my own warehouse, but they have not been deleted in my own warehouse.

Reason:
git is distributed, which means that everyone's computer will store a snapshot of the complete warehouse. So the branches created by others also have snapshots on their own computers.

solve:

Use the following command to synchronize the "pruned" branch and maintain the consistency of the branch.

git remote prune origin

example:

➜  xxx git:(main) git remote prune origin
Pruning origin
URL: git@github.com:xxx/xxx.git
 * [pruned] origin/xxx
 * [pruned] origin/xxx
 * [pruned] origin/xxx
 * [pruned] origin/xxx
 * [pruned] origin/xxx
 * [pruned] origin/xxx
 * [pruned] origin/xxx
 * [pruned] origin/xxx
 * [pruned] origin/xxx```

Guess you like

Origin blog.csdn.net/Morris_/article/details/129395468