git add <filename>无效

时间:2018-06-12 18:18:01

标签: windows git

当我输入

git add *.c

显示的错误是

warning: could not open directory 'AppData/Local/Application Data/': 
Permission denied
warning: could not open directory 'AppData/Local/ElevatedDiagnostics/': Permission denied
warning: could not open directory 'AppData/Local/History/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/INetCache/Content.IE5/': Permission d                                                                                                          enied
warning: could not open directory 'AppData/Local/Microsoft/Windows/INetCache/Low/Content.IE5/': Permissi                                                                                                          on denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/Temporary Internet Files/': Permissio                                                                                                          n denied
warning: could not open directory 'AppData/Local/Temporary Internet Files/': Permission denied
warning: could not open directory 'Application Data/': Permission denied
warning: could not open directory 'Cookies/': Permission denied
warning: could not open directory 'Documents/My Music/': Permission denied
warning: could not open directory 'Documents/My Pictures/': Permission denied
warning: could not open directory 'Documents/My Videos/': Permission denied
      0 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
warning: could not open directory 'Local Settings/': Permission denied
warning: could not open directory 'My Documents/': Permission denied
warning: could not open directory 'NetHood/': Permission denied
warning: could not open directory 'PrintHood/': Permission denied
warning: could not open directory 'Recent/': Permission denied
warning: could not open directory 'SendTo/': Permission denied
warning: could not open directory 'Start Menu/': Permission denied
warning: could not open directory 'Templates/': Permission denied
warning: LF will be replaced by CRLF in .atom/packages/script/examples/colored_diagnostics.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in .atom/packages/script/examples/hello.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in .atom/recovery/stringdel-c5a98d.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/Programs/Python/Python36-32/Lib/site-packages/nump                                                                                                          y/distutils/mingw/gfortran_vs2003_hack.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/Programs/Python/Python36-32/Lib/site-packages/nump                                                                                                          y/f2py/src/fortranobject.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/Programs/Python/Python36-32/Lib/site-packages/nump                                                                                                          y/f2py/tests/src/array_from_pyobj/wrapmodule.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/atom/app-1.27.0/resources/app/apm/node_modules/npm                                                                                                          /node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/atom/app-1.27.1/resources/app/apm/node_modules/npm                                                                                                          /node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in AppData/Local/atom/app-1.27.2/resources/app/apm/node_modules/npm                                                                                                          /node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c.
The file will have its original line endings in your working directory.
1241365 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
2219951 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
2611925 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
2758249 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
2990144 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
3176253 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
3360807 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
3523597 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
3746325 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
3964192 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
4150814 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
4335693 [sig] bash 22680! sigpacket::process: Suppressing signal 18 to win32 process (pid 23616)
warning: LF will be replaced by CRLF in Desktop/exploringBB-master/chp03/HelloWorldSleep.c.
....

请帮帮我。我不知道该怎么做才能添加文件。我的存储库文件夹中有一些没有权限的文件。如何更改这些权限,或者我应该更改我的存储库文件夹&gt; 我目前在Windows下工作。

5 个答案:

答案 0 :(得分:1)

似乎您正在尝试在用户目录内执行git操作。 C:\Users\{user-name}

请确保您的git bash或cmd指向正确的文件夹。

我遇到了同样的问题,通过导航到正确的文件夹,它对我来说很好

建议使用cd foldername,然后再次cd foldername进行导航

答案 1 :(得分:1)

就我而言,我通过运行以下命令解决了此错误:

git init
git add -A
git Commit -a -m "your message"

答案 2 :(得分:0)

您只需要删除日志文件即可。

使用命令

rm -rf .git

它将解决您的问题。输入此命令之前,请记住一件事,它将清除所有日志文件并删除.git文件夹。

答案 3 :(得分:0)

只需更改实际文件所在的目录,然后列出它们(ls -l)。你会在那里找到你的文件。完成此操作后,您的命令将正常运行 git add <filename>

我所做的是:

sarat@DESKTOP-9BPO08D MINGW64 /d
$ cd files1

sarat@DESKTOP-9BPO08D MINGW64 /d/files1
$ git init
Initialized empty Git repository in D:/files1/.git/

sarat@DESKTOP-9BPO08D MINGW64 /d/files1 (master)
$ ls -l
total 1
-rw-r--r-- 1 sarat 197609 396 May 25 21:15 Camera_Follow.cs

sarat@DESKTOP-9BPO08D MINGW64 /d/files1 (master)
$ git add Camera_Follow.cs

sarat@DESKTOP-9BPO08D MINGW64 /d/files1 (master)
$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   Camera_Follow.cs

答案 4 :(得分:0)

好像你没有在你的文件夹中初始化 git,

开始:

git init 
git status
git add -A 

它会起作用