在开发中,我们经常遇到,本地仓库的分支跟远程仓库的分支不一致了,虽然这不影响我们正常的代码提交,但是看着很不爽,这时该怎么办?如果你也遇到同样的烦恼,请往下看:
Admin@WW051 MINGW64 /f/HYB/MicroService (master)
$ git branch -r
origin/HEAD -> origin/master
origin/dev-V3.5.3
origin/dev-V3.6.0
origin/dev-V3.6.1
origin/dev-V3.6.2
origin/dev-V3.7.0
origin/dev-V3.7.1
origin/dev-V3.8.0
origin/dev-chengdu-data
origin/master
origin/test-V3.7
去GitLab中查看分支,如下表,发现明显不符。
Admin@WW051 MINGW64 /f/HYB/MicroService (master)
$ git remote show origin
* remote origin
HEAD branch: master
Remote branches:
dev-V3.7.0 tracked
dev-V3.7.1 tracked
dev-V3.8.0 tracked
dev-chengdu-data tracked
master tracked
refs/remotes/origin/dev-V3.5.3 stale (use 'git remote prune' to remove)
refs/remotes/origin/dev-V3.6.0 stale (use 'git remote prune' to remove)
refs/remotes/origin/dev-V3.6.1 stale (use 'git remote prune' to remove)
refs/remotes/origin/dev-V3.6.2 stale (use 'git remote prune' to remove)
test-V3.7 tracked
Local branches configured for 'git pull':
dev-V3.6.0 merges with remote dev-V3.6.0
......
Local refs configured for 'git push':
dev-V3.7.0 pushes to dev-V3.7.0 (up to date)
......
Admin@WW051 MINGW64 /f/HYB/MicroService (master)
$ git remote prune origin
Pruning origin
* [pruned] origin/dev-V3.5.3
* [pruned] origin/dev-V3.6.0
* [pruned] origin/dev-V3.6.1
* [pruned] origin/dev-V3.6.2
Admin@WW051 MINGW64 /f/HYB/MicroService (master)
$ git branch -r
origin/HEAD -> origin/master
origin/dev-V3.7.0
origin/dev-V3.7.1
origin/dev-V3.8.0
origin/dev-chengdu-data
origin/master
origin/test-V3.7
Admin@WW051 MINGW64 /f/HYB/MicroService (master)
$ git branch -a
dev-V3.6.0
dev-V3.6.1
dev-V3.6.2
dev-V3.7.0
dev-V3.7.1
dev-chengdu-data
* master
test-V3.7
remotes/origin/HEAD -> origin/master
remotes/origin/dev-V3.7.0
remotes/origin/dev-V3.7.1
remotes/origin/dev-V3.8.0
remotes/origin/dev-chengdu-data
remotes/origin/master
remotes/origin/test-V3.7
注意:删除本地仓库的时候确保代码都已经提交了
Admin@WW051 MINGW64 /f/HYB/MicroService (master)
$ git branch -d dev-V3.6.0 dev-V3.6.1 dev-V3.6.2
Deleted branch dev-V3.6.0 (was 8abce772).
Deleted branch dev-V3.6.1 (was b7b95fa6).
Deleted branch dev-V3.6.2 (was 6b1151e2).
Admin@WW051 MINGW64 /f/HYB/MicroService (master)
$ git checkout dev-V3.8.0
Switched to a new branch 'dev-V3.8.0'
Branch 'dev-V3.8.0' set up to track remote branch 'dev-V3.8.0' from 'origin'.
Admin@WW051 MINGW64 /f/HYB/MicroService (dev-V3.8.0)
$ git branch -a
dev-V3.7.0
dev-V3.7.1
* dev-V3.8.0
dev-chengdu-data
master
test-V3.7
remotes/origin/HEAD -> origin/master
remotes/origin/dev-V3.7.0
remotes/origin/dev-V3.7.1
remotes/origin/dev-V3.8.0
remotes/origin/dev-chengdu-data
remotes/origin/master
remotes/origin/test-V3.7
|