相关疑难解决方法(0)

列出没有遥控器的所有本地分支

问题:我想要一种删除没有遥控器的所有本地分支的方法.很容易将分支的名称输入到a中git branch -D {branch_name},但我如何首先获得该列表?

例如:

我创建了一个没有远程的新分支:

$ git co -b no_upstream
Run Code Online (Sandbox Code Playgroud)

我列出了所有的分支,只有一个有远程

$ git branch -a
master
* no_upstream
remotes/origin/HEAD -> origin/master
remotes/origin/master
Run Code Online (Sandbox Code Playgroud)

我可以运行什么命令来获得no_upstream答案?

我可以跑git rev-parse --abbrev-ref --symbolic-full-name @{u},这将表明它没有遥控器:

$ git rev-parse --abbrev-ref --symbolic-full-name @{u}
error: No upstream configured for branch 'no_upstream'
error: No upstream configured for branch 'no_upstream'
fatal: ambiguous argument '@{u}': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] …
Run Code Online (Sandbox Code Playgroud)

git git-remote

72
推荐指数
7
解决办法
3万
查看次数

Git:如何列出跟踪不再存在的远程分支的本地分支?

如何列出出现(按照.git/config)跟踪不再存在的远程分支的任何本地分支?在这种情况下,远程分支机构在GitHub上,但我怀疑它们的位置没有相关性.

例如:

  1. 我有地方分支机构,a,b,cd.
  2. a正在跟踪origin/ac正在跟踪origin/c.
  3. b并且d不跟踪远程分支.
  4. origin/a已被合并回主服务器并在存储库清理期间被删除; 我不再需要保留本地分支a.
  5. 如果本地分支a签出到工作树,则运行git fetchgit pull导致错误Your configuration specifies to merge with the ref 'a' from the remote, but no such ref was fetched.

如何生成仅包含a其他本地分支的列表,这些分支似乎跟踪不再存在的远程分支?

我想识别这些,以便我可以删除我不再需要的过时的本地分支.

该列表不应包括本地分支bd不跟踪远程分支,也不c应该是跟踪origin/c,这仍然存在.

git

13
推荐指数
4
解决办法
4606
查看次数

标签 统计

git ×2

git-remote ×1