代码之家  ›  专栏  ›  技术社区  ›  ReynierPM

为什么命令“git fetch-p”会同时带来与已删除和新分支相同的分支?

  •  1
  • ReynierPM  · 技术社区  · 5 年前

    我有一个奇怪的“问题”(根本不影响我,因为分支确实存在于本地和远程),我对此很好奇。我不确定这是我缺少的配置还是我确实有配置,但正如我所说的,这真的很奇怪。

    每次我这样做 git fetch -p 我拿到了树枝 [deleted] [new branch] 唯一的区别是分行名称前有一个大写字母,如下例所示:

    λ git checkout development && git pull origin development && git fetch -p
    Switched to branch 'development'
    Your branch is up to date with 'origin/development'.
    From github.com:ers/case
     * branch              development -> FETCH_HEAD
    Already up to date.
    From github.com:ers/case
     - [deleted]           (none)     -> origin/hotfix/DISPUTELAB-4991
     * [new branch]        Hotfix/DISPUTELAB-4991 -> origin/Hotfix/DISPUTELAB-4991
    

    这是命令的结果 git config --list :

    λ git config --list                                                                                                                               
    http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt                                                                               
    http.sslbackend=openssl                                                                                                                           
    diff.astextplain.textconv=astextplain                                                                                                             
    filter.lfs.clean=git-lfs clean -- %f                                                                                                              
    filter.lfs.smudge=git-lfs smudge -- %f                                                                                                            
    filter.lfs.process=git-lfs filter-process                                                                                                         
    filter.lfs.required=true                                                                                                                          
    credential.helper=manager                                                                                                                         
    core.editor=nano.exe                                                                                                                              
    core.autocrlf=true                                                                                                                                
    core.fscache=true                                                                                                                                 
    core.symlinks=false                                                                                                                               
    core.autocrlf=true                                                                                                                                
    winupdater.recentlyseenversion=2.23.0.windows.1                                                                                                   
    user.name=reypm                                                                                                                              
    user.email=<********>
    alias.l=log --pretty=format:%C(yellow)%h\ %ad%Cred%d\ %Creset%s%Cblue\ [%cn] --decorate --date=short                                              
    alias.lg='git log --graph --oneline --decorate --all'                                                                                             
    alias.a=add                                                                                                                                       
    alias.ap=add -p                                                                                                                                   
    alias.aa=add .                                                                                                                                    
    alias.ac=!git add -A && git commit -m                                                                                                             
    alias.c=commit --verbose                                                                                                                          
    alias.ca=commit -a --verbose                                                                                                                      
    alias.cm=commit -m                                                                                                                                
    alias.cam=commit -a -m                                                                                                                            
    alias.m=commit --amend --verbose                                                                                                                  
    alias.d=diff                                                                                                                                      
    alias.ds=diff --stat                                                                                                                              
    alias.dc=diff --cached                                                                                                                            
    alias.a=add                                                                                                                                       
    alias.ap=add -p                                                                                                                                   
    alias.aa=add .                                                                                                                                    
    alias.c=commit --verbose                                                                                                                          
    alias.ca=commit -a --verbose                                                                                                                      
    alias.cm=commit -m                                                                                                                                
    alias.cam=commit -a -m                                                                                                                            
    alias.m=commit --amend --verbose                                                                                                                  
    alias.d=diff                                                                                                                                      
    alias.ds=diff --stat                                                                                                                              
    alias.dc=diff --cached                                                                                                                            
    alias.s=status -s                                                                                                                                 
    alias.co=checkout                                                                                                                                 
    alias.cob=checkout -b                                                                                                                             
    alias.b=!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'  
    alias.la=!git config -l | grep alias | cut -c 7-                                                                                                  
    commit.gpgsign=false                                                                                                                              
    gui.pruneduringfetch=true                                                                                                                         
    smartgit.submodule.fetchalways=true                                                                                                               
    smartgit.submodule.update=true                                                                                                                    
    smartgit.submodule.initializenew=true                                                                                                             
    push.recursesubmodules=check                                                                                                                      
    core.repositoryformatversion=0                                                                                                                    
    core.filemode=false                                                                                                                               
    core.bare=false                                                                                                                                   
    core.logallrefupdates=true                                                                                                                        
    core.symlinks=false                                                                                                                               
    core.ignorecase=true                                                                                                                              
    remote.origin.url=git@github.com:ers/case.git                                                                                   
    remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*                                                                                           
    user.name=reypm                                                                                                                                 
    user.email=<******>
    branch.development.remote=origin                                                                                                                  
    branch.development.merge=refs/heads/development                                                                                                   
    branch.master.remote=origin                                                                                                                       
    branch.master.merge=refs/heads/master                                                                                                             
    gitflow.branch.master=master                                                                                                                      
    gitflow.branch.develop=development                                                                                                                
    gitflow.prefix.feature=feature/                                                                                                                   
    gitflow.prefix.bugfix=bugfix/                                                                                                                     
    gitflow.prefix.release=release/                                                                                                                   
    gitflow.prefix.hotfix=hotfix/                                                                                                                     
    gitflow.prefix.support=support/                                                                                                                   
    gitflow.prefix.versiontag=                                                                                                                        
    gitflow.path.hooks=D:/dev/docker/case/.git/hooks
    

    除了我之前所说的,我必须说我正在从Windows使用Git。

    我也注意到了 core.ignorecase=true 但我不确定如果我将其更改为false,或者如果我应该保持为true,该怎么办,因为我在Windows中,而且众所周知,文件名等方面存在问题。

    有趣的是,带有大写字母的远程分支机构在起源中并不存在:

    λ git fetch -p                                                                                                         
    From github.com:ers/case
     - [deleted]             (none)     -> origin/Hotfix/DISPUTELAB-4991                
     * [new branch]          hotfix/DISPUTELAB-4991  -> origin/hotfix/DISPUTELAB-4991   
    
    λ git branch -r | grep DISPUTELAB-4991                                              
      origin/hotfix/DISPUTELAB-4991     
    

    有人认为这会导致“问题”吗?我完全迷失在这一点上。

    0 回复  |  直到 5 年前
        1
  •  1
  •   torek    5 年前

    origin/hotfix/DISPUTELAB-4991 显然与 origin/Hotfix/DISPUTELAB-4991 ,就像波兰语和波兰语是两个完全不同的词一样。 1.

    Git理解这一事实并正确处理。另一方面,你的操作系统坚持认为 hotfix Hotfix 相同的 。所以你会对这个案子感到奇怪。

    Git有时会按照Linus Torvalds和Git的意图,将这些名称存储在不同的文本文件中。但有时Git会将这些名称保存在磁盘上的文件夹和文件名中,然后它们会变得相同。这个 core.ignorecase 设置没有帮助,原因有两个:

    1. 它纯粹是提供信息:它告诉Git 关于 你的系统,但实际上并没有改变Git对文件名的任何处理。(这可能是应该的,但不是。)
    2. 它仅用于从提交到工作树中提取的文件,不用于分支名称、标记名称、远程跟踪名称和其他此类引用。

    Git的需求正在逐渐增长 2. 针对这些情况,在存储库中更好地处理文件名。它也非常需要,但 更好地处理分支和其他参考名称。由于第二个问题,最好只使用所有小写字母 全部的 分支、标签和其他名称。只要假装大写字母不存在:避免使用它,你就永远不会发现Git在大小写折叠系统上表现得很奇怪。


    1. “波兰人涂了鞋油”这句话很有道理;带有“波兰人涂鞋油”的变体在最后一刻变成了杂草。:-)

    2. 这与正在进行的稀疏签出工作有关。这是处理问题的一种方法,它也适用于我们在Linux和MacOS上使用Git时遇到的其他问题,例如,MacOS坚持规范化文件名,如 schön 尽管我认为这仍然不太正确。