尝试使用符号链接文件夹添加,提交和推送时出现Git错误

时间:2016-09-09 16:32:07

标签: git

我有一个用遥控器克隆的本地目录。但是,当我尝试添加,提交,推送到远程服务器时,我得到以下内容。

任何帮助表示赞赏。

$ git add .
warning: LF will be replaced by CRLF in .meteor/.finished-upgraders.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in .meteor/.gitignore.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in .meteor/.id.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in .meteor/packages.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in .meteor/platforms.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in .meteor/release.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in .meteor/versions.
The file will have its original line endings in your working directory.
error: readlink("node_modules"): Function not implemented
error: unable to index file node_modules
fatal: adding files failed

然后:

$ git commit -a -m "commit"

On branch master

Initial commit

Untracked files:
        .gitignore
        .meteor/
        node_modules
        server/
        tsconfig.json
        tslint.json
        typings

nothing added to commit but untracked files present

然后:

$ git push
error: src refspec master does not match any.
error: failed to push some refs to 'https://git.heroku.com/remote-thewhozoo.git'

当我:

$ git remote show origin
* remote origin
  Fetch URL: https://git.heroku.com/remote-thewhozoo.git
  Push  URL: https://git.heroku.com/remote-thewhozoo.git
  HEAD branch: (unknown)
  Local branch configured for 'git pull':
    master merges with remote master

如您所见,我有符号链接。

enter image description here

1 个答案:

答案 0 :(得分:1)

尝试添加文件时已经出现问题:

error: readlink("node_modules"): Function not implemented
error: unable to index file node_modules
fatal: adding files failed

一种解决方案是明确添加未跟踪的文件,而不是一次性添加所有文件并跳过node_modules。这将使您能够提交并推送您的更改。但我认为从长远来看这不会解决你的问题。

错误消息指示node_modules是符号链接(符号链接)。因此,您有两种选择:如果您不需要对该文件夹进行版本化,则可以通过添加.gitignore将其添加到/node_modules。如果您需要跟踪它,可以将core.symlink设置为true

git config core.symlinks true

在任何一种情况下,您都可以运行git add .而不会出现任何错误。