我遇到了一个奇怪的问题,我无法从远程签出 .gitattributes。最近添加了 .gitattributes 文件,我想将其拉入并进行一些更改。我做到了git pull
,它说我的分支是最新的,但该文件没有出现在我的本地机器中(ls -al
没有显示 .gitattributes)。我试过了git checkout origin .gitattributes
,它说它不匹配任何文件。但如果我这样做git rm .gitattributes
,则git status
表明 .gitattributes 已上演以供删除。有谁知道如何解决这个问题?
编辑:
$ git status
On branch YansBranch
Your branch is up-to-date with 'origin/YansBranch'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
// some file changes due to auto converting crlf to lf
no changes added to commit (use "git add" and/or "git commit -a")
$ ls -al
total 5
drwxr-xr-x Administ 4096 Dec 23 12:11 .
drwxr-xr-x Administ 0 Aug 5 16:38 ..
drwxr-xr-x Administ 4096 Dec 23 12:13 .git
-rw-r--r-- Administ 955 Dec 23 10:57 .gitignore
drwxr-xr-x Administ 0 Aug 5 16:39 win
$ git rm .gitattributes
rm '.gitattributes'
$ git status
On branch YansBranch
Your branch is up-to-date with 'origin/YansBranch'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: .gitattributes
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
// some file changes due to auto converting crlf to lf
这是我的 .gitattributes
# THIS IS ONLY FOR THE gitattributes REPOSITORY.
# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto
#
# The above will handle all files NOT found below
#
# These files are text and should be normalized (Convert crlf => lf)
*.gitattributes text
.gitignore text
*.md text
# c++
#sources
*.C text
*.cc text
*.cxx text
*.cpp text
*.c++ text
*.hpp text
*.h text
*.h++ text
*.hh text
# Compiled Object files
*.slo binary
*.lo binary
*.o binary
*.obj binary
# Precompiled Headers
*.gch binary
*.pch binary
# Compiled Dynamic libraries
*.so binary
*.dylib binary
*.dll binary
# Compiled Static libraries
*.lai binary
*.la binary
*.a binary
*.lib binary
# Executables
*.exe binary
*.out binary
*.app binary
# c#
*.cs diff=csharp