Git工作树没有显示分支名称,但识别分支。

huangapple go评论55阅读模式
英文:

Git worktrees not showing branch names, but recognizing branches

问题

I recently enabled Windows Subsystem for Linux 2 (WSL2) on Windows 10 and installed Debian.

我最近在Windows 10上启用了Windows子系统用于Linux 2(WSL2),并安装了Debian。

I also installed zsh with several plugins. You can see the dotfiles repo here: https://github.com/art3xias23/wsl-dotfiles

我还安装了带有多个插件的zsh。您可以在此处查看dotfiles存储库:https://github.com/art3xias23/wsl-dotfiles

I'm using Windows Terminal, however there is no difference if I use gitbash and debian on their own or inside Windows Terminal.

我正在使用Windows终端,但如果我单独使用gitbash和debian,或者在Windows终端中使用它们,都没有任何区别。

My issue is:

我的问题是:

I have a repo with 3 worktrees on my windows home directory.

我有一个在Windows家目录中有3个工作树的存储库。

When I use git bash for windows I can see the branch names fine after the directory.

当我在Windows上使用git bash时,我可以在目录后面很好地看到分支名称。

GitBash

Repo1: Git工作树没有显示分支名称,但识别分支。

Repo2: Git工作树没有显示分支名称,但识别分支。

GitBash

Repo1: Git工作树没有显示分支名称,但识别分支。

Repo2: Git工作树没有显示分支名称,但识别分支。

Now when I move to zsh and try to access the same windows home directory worktrees, I can see the branch name for only the first repo and not the second or third (The first repo contains the .git directory)

现在当我切换到zsh并尝试访问相同的Windows家目录工作树时,我只能看到第一个存储库的分支名称,而不是第二个或第三个(第一个存储库包含.git目录)

I also don't see any other branch names, like the one for my wsl-dotfiles repo, which is my wsl home directory

我还看不到其他分支名称,比如我的wsl-dotfiles存储库,它是我的wsl家目录

Repo1: Git工作树没有显示分支名称,但识别分支。

Repo2: Git工作树没有显示分支名称,但识别分支。

Repo1: Git工作树没有显示分支名称,但识别分支。

Repo2: Git工作树没有显示分支名称,但识别分支。

Would anyone know why the branch names are not appearing.

是否有人知道为什么分支名称没有显示。

英文:

I recently enabled Windows Subsystem for Linux 2 (WSL2) on Windows 10 and installed Debian.

I also installed zsh with several plugins. You can see the dotfiles repo here: https://github.com/art3xias23/wsl-dotfiles

I'm using Windows Terminal, however there is no difference if I use gitbash and debian on their own or inside Windows Terminal.

My issue is:

I have a repo with 3 worktrees on my windows home directory.

When I use git bash for windows I can see the branch names fine after the directory.

GitBash

Repo1: Git工作树没有显示分支名称,但识别分支。

Repo2: Git工作树没有显示分支名称,但识别分支。

ZSHELL

Now when I move to zsh and try to access the same windows home directory worktrees, I can see the branch name for only the first repo and not the second or third (The first repo contains the .git directory)

I also don't see any other branch names, like the one for the my wsl-dotfiles repo, which is my wsl home directory

====================================

Git工作树没有显示分支名称,但识别分支。

====================================

Repo1: Git工作树没有显示分支名称,但识别分支。

====================================

Repo2: Git工作树没有显示分支名称,但识别分支。

====================================

Would anyone know why the branch names are not appearing.

答案1

得分: 0

这似乎是zsh的默认行为。请按照git文档中的说明启用显示git分支名称:

https://git-scm.com/book/uz/v2/Appendix-A%3A-Git-in-Other-Environments-Git-in-Zsh

当涉及到提示符自定义时,Zsh在某种程度上与Bash相当兼容,但它也允许您在右侧显示提示符。要在右侧包括分支名称,请将以下内容添加到您的~/.zshrc文件:

setopt prompt_subst
. ~/git-prompt.sh
export RPROMPT='$(__git_ps1 "%s")'
英文:

Seems like this is the default behavior of zsh. Follow instructions from git documentation to enable showing of git branch names:

https://git-scm.com/book/uz/v2/Appendix-A%3A-Git-in-Other-Environments-Git-in-Zsh

> Zsh happens to be fairly compatible with Bash when it comes to prompt
> customization, but it allows you to have a right-side prompt as well.
> To include the branch name on the right side, add these lines to your
> ~/.zshrc file:
>
> setopt prompt_subst
> . ~/git-prompt.sh
> export RPROMPT=$'$(__git_ps1 "%s")'

答案2

得分: 0

  1. 主目录分支未显示:

    在我的.p10k.zsh文件中注释掉此行解决了此问题

    typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'

  2. Git工作树分支名称未显示。

    这里这里所讨论的,尚不支持。

英文:

Below I'll display my findings and close this question.

  1. Home directory branch not showing:

    Commenting out this line in my.p10k.zsh solved the issue

    typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'

  2. Git worktree branch name not showing.

    Not yet supported as discussed here
    and here

答案3

得分: 0

抱歉,我能知道你最后做了什么吗?我在想我们如何继续使用 p10k 并还原工作树?

英文:

sorry for the dumb question, but can i know what did you do in the end? I'm wondering how can we still use p10k and revert worktree?

huangapple
  • 本文由 发表于 2023年5月17日 17:29:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76270569.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定