代码之家  ›  专栏  ›  技术社区  ›  Miserable Variable

*core.excludesfile中的war导致git add忽略*.p12文件

git
  •  3
  • Miserable Variable  · 技术社区  · 6 年前

    这太让人困惑了。使用shell命令更容易显示。

    注意我的 ~/.gitconfig 指定 excludesfile = /home/I063510/.gitignore [core]

    检查原因。p12被忽略,管道到sed以屏蔽我的用户id

    $> git check-ignore -v check.p12 | sed -n 's,/home/[^/]*,~,p'
    ~/.gitignore:11:*.war   check.p12
    

    用图案标出线条 ^*.war

    $> sed -i.orig 's,^*.war,#&,' ~/.gitignore
    $> git check-ignore -v check.p12 | sed -n 's,/home/[^/]*,~,p'
    $> 
    

    还原原始文件并验证是否忽略.p12

    $> mv -f ~/.gitignore.orig ~/.gitignore
    $> git check-ignore -v check.p12 | sed -n 's,/home/[^/]*,~,p'
    ~/.gitignore:11:*.war   check.p12
    

    git版本:

    $> git --version
    git version 2.17.0
    

    更新

    # git check-ignore -v check.p12
    
    # git config core.excludesfile c:/temp/.gitignore
    
    # git check-ignore -v check.p12
    c:/temp/.gitignore:1:*.war      check.p12
    
    # git --version
    git version 2.20.1.windows.1
    

    忘了说,这种情况只发生在 ~core.excludesfile~ ,不在 ~core.workdir~/.gitignore

    1 回复  |  直到 6 年前
        1
  •  0
  •   VonC    6 年前

    我在用cygwin git

    试着用普通的 Git for Windows PortableGit-2.20.1-64-bit.7z.exe ),解压缩 C:\Git ,并且 simplified PATH 在一个 CMD

    set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
    set GH=C:\path\to\git
    set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%
    

    然后你可以打字 bash
    看看问题是否仍然存在。