Git - 缺少一些文件 [英] Git-missing some files

查看:163
本文介绍了Git - 缺少一些文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试将本地存储库推送到空的远程存储库时,我正在执行以下操作:

  git添加。 
git status

当我运行 git status ,我看到有些文件没有被暂存,这里是我的git bash和我的本地工作副本的截图:



我的忽略文件:

  *。* 

#####目录
!CefSharp / Internals / *
!CefSharp / Properties / *

!CefSharp.BrowserSubprocess / Properties / *

!CefSharp.Core / Internals / *
!CefSharp.Core / Win32 / *

!CefSharp.Example / ExtensionMethods / *
!CefSharp.Example / Properties
!CefSharp.Example / Proxy
!CefSharp.Example / Resources

!CefSharp.WinForms / Internals / *
!CefSharp.WinForms / Properties / *

!CefSharp.WinForms.Example / Minimal / *
!CefSharp .WinForms.Example / Properties / *
!CefSharp.WinForms.Example / Resources / *
!CefSharp.WinForms.Example / Tools / *

!ipch / *
!packages / *
!Resources / *
!RexCao / Properties / *

!SysHandle / Properties / *

!TimesheetUpdater / Properties / *
!TimesheetUpdater / Resources / *
!TimesheetUpdater / Tools / *

!TSNetChecker / Properties / *
!TSNetChecker / Resource / *
!TSNetChecker / Resources / *
!TSNetChecker / Tools / *

!UIThreadTest / Properties / *

!Win32 / *

#####文件
!CefSharp / * .cs
!CefSharp / *。csproj

!CefSharp.BrowserSubprocess / app *
!CefSharp.BrowserSubprocess / * .csproj
!CefSharp.BrowserSubprocess / * .cs
$ b!CefSharp.BrowserSubprocess.Core / *。cpp
!CefSharp.BrowserSubprocess.Core / *。h
!CefSharp.BrowserSubprocess.Core / *。vcxproj。*
!CefSharp.BrowserSubprocess.Core / *。config

!CefSharp.Core / *。cpp
!CefSharp。 Core / *。h
!CefSharp.Core / *。vcxproj。*
!CefSharp.Core / *。config
$ b!CefSharp.Example / * .cs
!CefSharp.Example / *。csproj

!CefSharp.WinForms / *。csproj
!CefShar CephSharp.WinForms.Example / * .cs
!CefSharp.WinForms.Example / app。*
!CefSharp.WinForms.Example / * .csi

!CefSharp.WinForms.Example / * .csproj。*
!CefSharp.WinForms.Example / * .iico
!CefSharp.WinForms.Example / *。config
!CefSharp.WinForms.Example / * .resx

!RexCao / * .cs
!RexCao / *。csproj

!SysHandle / * .cs
!SysHandle / *。csproj

!TimesheetUpdater / * .iico
!TimesheetUpdater / * .cs
!TimesheetUpdater / * .resx
!TimesheetUpdater / *。csproj

!TSNetChecker / * .cs
!TSNetChecker / * .resx
!TSNetChecker / * .ico
!TSNetChecker / *。csproj

!UIThreadTest / *。config
!UIThreadTest / * .cs
!UIThreadTest / * .resx
!UIThreadTest / *。csproj

!.gitignore
!*。ps1
!*。yml
!*。bat
!*。props
!*。snk
!*。sdf
!*。sln

我的问题是:为什么有些文件错过了?

解决方案

为了在目录下包含全部文件,y您必须指定为:

 !目录/ ** 

不带星号( * )。

由于您已指定忽略所有文件

  *。* 

除了包含的内容()外,您必须正确指定要添加的文件。

背景



正如你可以在 specifications ,一个星号与目录下的文件直接匹配。不是子目录中的文件。



为了 un-ignore 目录中的所有文件,您需要使用两个连续的星号:


连续两个星号( ** )与满$ b $匹配b路径名可能有特殊含义:




  • 领先的 ** 后面跟斜杠表示所有目录匹配。例如, ** / foo 与任何地方的文件或目录foo匹配,
    与模式 foo ** / foo / bar 匹配文件或目录 bar
    直接位于任何地方目录 foo


  • 结尾的 / ** 匹配里面的所有内容。例如, abc / ** 匹配目录 abc 内的所有文件,相对于$的位置b $ b .gitignore 文件,具有无限深度。


  • 斜杠后跟两个连续的星号那么斜线匹配零个或多个目录。例如, a / ** / b 匹配 a / b
    a / x / b a / x / y / b 等等。




其他连续的星号被视为无效。


When I'm trying to push my local repository to an empty remote repository, I am doing the following:

git add .
git status

When im running git status, I see that some files are not staged, here is a screenshot of my git bash and my local working copy:

My ignore file:

*.*

#####Directories
!CefSharp/Internals/*
!CefSharp/Properties/*

!CefSharp.BrowserSubprocess/Properties/*

!CefSharp.Core/Internals/*
!CefSharp.Core/Win32/*

!CefSharp.Example/ExtensionMethods/*
!CefSharp.Example/Properties
!CefSharp.Example/Proxy
!CefSharp.Example/Resources

!CefSharp.WinForms/Internals/*
!CefSharp.WinForms/Properties/*

!CefSharp.WinForms.Example/Minimal/*
!CefSharp.WinForms.Example/Properties/*
!CefSharp.WinForms.Example/Resources/*
!CefSharp.WinForms.Example/Tools/*

!ipch/*
!packages/*
!Resources/*
!RexCao/Properties/*

!SysHandle/Properties/*

!TimesheetUpdater/Properties/*
!TimesheetUpdater/Resources/*
!TimesheetUpdater/Tools/*

!TSNetChecker/Properties/*
!TSNetChecker/Resource/*
!TSNetChecker/Resources/*
!TSNetChecker/Tools/*

!UIThreadTest/Properties/*

!Win32/*

#####Files
!CefSharp/*.cs
!CefSharp/*.csproj

!CefSharp.BrowserSubprocess/app*
!CefSharp.BrowserSubprocess/*.csproj
!CefSharp.BrowserSubprocess/*.cs

!CefSharp.BrowserSubprocess.Core/*.cpp
!CefSharp.BrowserSubprocess.Core/*.h
!CefSharp.BrowserSubprocess.Core/*.vcxproj.*
!CefSharp.BrowserSubprocess.Core/*.config

!CefSharp.Core/*.cpp
!CefSharp.Core/*.h
!CefSharp.Core/*.vcxproj.*
!CefSharp.Core/*.config

!CefSharp.Example/*.cs
!CefSharp.Example/*.csproj

!CefSharp.WinForms/*.csproj
!CefSharp.WinForms/*.cs

!CefSharp.WinForms.Example/*.cs
!CefSharp.WinForms.Example/app.*
!CefSharp.WinForms.Example/*.csproj.*
!CefSharp.WinForms.Example/*.ico
!CefSharp.WinForms.Example/*.config
!CefSharp.WinForms.Example/*.resx

!RexCao/*.cs
!RexCao/*.csproj

!SysHandle/*.cs
!SysHandle/*.csproj

!TimesheetUpdater/*.ico
!TimesheetUpdater/*.cs
!TimesheetUpdater/*.resx
!TimesheetUpdater/*.csproj

!TSNetChecker/*.cs
!TSNetChecker/*.resx
!TSNetChecker/*.ico
!TSNetChecker/*.csproj

!UIThreadTest/*.config
!UIThreadTest/*.cs
!UIThreadTest/*.resx
!UIThreadTest/*.csproj

!.gitignore
!*.ps1
!*.yml
!*.bat
!*.props
!*.snk
!*.sdf
!*.sln

My question is: Why some files were missed?

解决方案

In order to include all files under a directory, you must specify it as:

!directory/**

not with a single asterisk (*).

Since you have specified to ignore all files

*.*

except the ones you include with a bang (!), you must specify correctly the files you want to add.

Background

As you can read in the specifications a single asterisk matches the files directly under the directory. Not files in the subdirectories.

In order to un-ignore all files in the directory, you need to use two consecutive asterisks:

Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:

  • A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".

  • A trailing "/**" matches everything inside. For example, "abc/**" matches all files inside directory "abc", relative to the location of the .gitignore file, with infinite depth.

  • A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.

Other consecutive asterisks are considered invalid.

这篇关于Git - 缺少一些文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆