删除远程分支命令:
1
|
$ git push origin :br03
|
或者:
1
|
$ git push origin --delete br03
|
另一个用户使用git fetch
并不能同步获取到br03分支被删除。
此命令没有更新的显示,说明并无删除的信息。
但执行git pull
时,报错。
1 2 3
|
$ git pull Your configuration specifies to merge with the ref 'br03' from the remote, but no such ref was fetched.
|
这肯定是执行git fetch时,报错。
1 2 3
|
$ git fetch origin br03 fatal: Couldn't find remote ref br03 fatal: The remote end hung up unexpectedly
|
但检查分支时,发现origin/br03还存在。
1 2 3 4 5 6 7 8
|
$ git br -a br01 br02 * br03 master remotes/origin/br01-remote remotes/origin/br03 remotes/origin/master
|
这说明,remotes/origin/*
这些远程跟踪分支,仅仅是远程分支的一个缓存,并且,不能通过git fetch
命令获取到分支删除的更新。
执行命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
$ git remote show origin * remote origin Fetch URL: git@github0123:jeremy0123/fetch.git Push URL: git@github0123:jeremy0123/fetch.git HEAD branch: master Remote branches: br01-remote tracked br02 tracked br03-remote tracked master tracked refs/remotes/origin/br03 stale (use 'git remote prune' to remove) Local branches configured for 'git pull': br01 merges with remote br01-remote br03 merges with remote br03 master merges with remote master Local refs configured for 'git push': br02 pushes to br02 (up to date) master pushes to master (local out of date)
|
发现refs/remotes/origin/br03
状态是stale(陈旧的),并且后面有命令提示。
1 2 3 4
|
$ git remote prune origin Pruning origin URL: git@github0123:jeremy0123/fetch.git * [pruned] origin/br03
|
或者执行
1 2 3 4 5 6 7
|
$ git fetch -p remote: Counting objects: 5, done. remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. From git@github0123:jeremy0123/fetch.git 04a6837..d49d143 master -> origin/master x [deleted] (none) -> origin/br03
|
在执行fetch之后,删除远程不存在的远程跟踪分支。
~~ EOF ~~