英文:
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
GitBash
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家目录
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
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
====================================
====================================
====================================
====================================
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
-
主目录分支未显示:
在我的.p10k.zsh文件中注释掉此行解决了此问题
typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'
-
Git工作树分支名称未显示。
英文:
Below I'll display my findings and close this question.
答案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?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论