我在本地机器上有两个目录,指向同一个远程 Git 仓库。当我在其中一个目录中输入命令 git branch -r
时,我会得到比另一个目录更长的远程分支列表。这是怎么可能的?
似乎在一个目录中会“隐藏”一些远程分支,并在另一个目录中可见。
我在本地机器上有两个目录,指向同一个远程 Git 仓库。当我在其中一个目录中输入命令 git branch -r
时,我会得到比另一个目录更长的远程分支列表。这是怎么可能的?
似乎在一个目录中会“隐藏”一些远程分支,并在另一个目录中可见。
git branch -r
显示的分支较少,也不包括最新的更改,而在另一个目录中一切都正常更新。git config -l
命令,发现缺少了 remote.origin.fetch
设置。运行以下命令解决了我的问题:git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
git fetch
From github.com:username/test2
2bd5e5e..2619d39 master -> origin/master
* [new branch] remotebr2 -> origin/remotebr2
* [new branch] remotebranch -> origin/remotebranch
我认为你应该进行获取和修剪操作:
prune
Deletes all stale tracking branches under <name>. These stale branches have already been removed from the remote repository referenced by <name>, but are still locally available in "remotes/<name>".
With --dry-run option, report what branches will be pruned, but do not actually prune them.
使用以下命令行:
git fetch
git remote prune origin
这两个代码库是否都是最新的?尝试运行 git fetch
命令看看能否解决问题。