简体   繁体   English

未为某些本地存储库设置豪华的git颜色

[英]posh-git colors not set for some local repos

I have two local repos for which I use posh-git, and in one of them, the branch colors show correctly according to the posh-git readme : 我有两个使用posh-git的本地存储库,其中之一是根据posh-git自述文件正确显示分支颜色的:

  • Cyan means the branch matches its remote 青色表示分支匹配其远程
  • Green means the branch is ahead of its remote (green light to push) 绿色表示分支位于其远端(绿色指示灯可推动)
  • Red means the branch is behind its remote 红色表示分支位于其遥控器的后面
  • Yellow means the branch is both ahead of and behind its remote 黄色表示分支位于其远程对象的前面和后面

But in my other repo, the branches are always in a cyan color, regardless of the state of local vs. remote. 但是在我的其他仓库中,无论本地与远程状态如何,分支始终为青色。

Between the two, I've run a diff on both $GitPromptSettings and git config -l , and neither show any color-related differences (only the remote origin, some branch names, and one of them has some gitflow settings). 在这两者之间,我对$GitPromptSettingsgit config -l都进行了比较,并且都没有显示任何与颜色相关的差异(仅远程原点,某些分支名称以及其中一个具有某些gitflow设置)。

If it could make any difference, the two are also from two separate GitHub private (organization) repos. 如果有什么不同,两者也来自两个单独的GitHub私有(组织)存储库。

What could be causing this, or what else could I do to troubleshoot? 是什么原因引起的,或者我还可以采取其他措施进行故障排除?

I suspect that your local branches aren't set to track anything upstream. 我怀疑您的本地分支机构未设置任何上游跟踪功能 This means that Git doesn't know which remote branches to compare them against. 这意味着Git不知道将哪个远程分支与之进行比较。

You can check this by inspecting the .git/config file inside your repository. 您可以通过检查存储库中的.git/config文件来进行检查。 Branches that are set to track upstream branches will contain a merge setting, eg 设置为跟踪上游分支的分支将包含merge设置,例如

[branch "master"]
        remote = origin
        merge = refs/heads/master

One easy way to set a tracking branch is to use the -u argument the next time you push , eg git push -u origin master . 设置跟踪分支的一种简单方法是在下次push时使用-u参数,例如git push -u origin master (You don't have to do this every time; this will set the option shown above the first time you use it). (您不必每次都这样做;这将设置您初次使用时显示的选项)。

From its documentation : 从其文档中

-u
--set-upstream

For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-less git-pull and other commands. 对于每个最新的或成功推送的分支,添加上游(跟踪)引用,该引用由无参数git-pull和其他命令使用。 For more information, see branch.<name>.merge in git-config . 有关更多信息,请参见git-config branch.<name>.merge

More information about setting a remote tracking branch on an existing branch can be found in this answer . 在此答案中可以找到有关在现有分支上设置远程跟踪分支的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM