首页 > 解决方案 > Git 说我的 .gitignore 路径无效,无法添加

问题描述

我有一个非常简单的问题,我不明白出了什么问题。我正在尝试暂存我的 .gitignore 文件以进行提交,但 Git 说路径无效。就这么平淡。我的终端输出粘贴在下面。如您所见,.gitignore 文件确实存在,但我无法添加它。

magnus@magnus:~/Documents/deep-rl-hex$ git status
On branch neural_net_added
Your branch is up to date with 'origin/neural_net_added'.

nothing to commit, working tree clean


magnus@magnus:~/Documents/deep-rl-hex$ ls -alt .git/
    total 68
    drwxr-xr-x   8 magnus magnus 4096 nov.  13 17:48 .
    -rw-r--r--   1 magnus magnus 2436 nov.  13 17:48 index
    -rw-r--r--   1 magnus magnus   41 nov.  13 17:48 ORIG_HEAD
    drwxr-xr-x   5 magnus magnus 4096 nov.  13 17:48 refs
    drwxr-xr-x 160 magnus magnus 4096 nov.  13 17:48 objects
    -rw-r--r--   1 magnus magnus 1427 nov.  13 17:39 .gitignore #.gitignore file is indeed here
    drwxr-xr-x   5 magnus magnus 4096 nov.  13 17:38 ..
    -rw-r--r--   1 magnus magnus   33 nov.  13 17:38 HEAD
    -rw-r--r--   1 magnus magnus  221 nov.  13 17:38 FETCH_HEAD
    -rw-r--r--   1 magnus magnus  348 nov.  13 17:28 config
    -rw-r--r--   1 magnus magnus    4 nov.  13 17:27 COMMIT_EDITMSG
    drwxr-xr-x   3 magnus magnus 4096 okt.  27 14:35 logs
    -rw-r--r--   1 magnus magnus  114 okt.  27 14:35 packed-refs
    drwxr-xr-x   2 magnus magnus 4096 okt.  27 14:35 hooks
    drwxr-xr-x   2 magnus magnus 4096 okt.  27 14:35 info
    drwxr-xr-x   2 magnus magnus 4096 okt.  27 14:35 branches
    -rw-r--r--   1 magnus magnus   73 okt.  27 14:35 description


magnus@magnus:~/Documents/deep-rl-hex$ git add .git/.gitignore
    error: Invalid path '.git/.gitignore'
    error: unable to add .git/.gitignore to index
    fatal: adding files failed

这里有什么问题?很明显,我缺少一些基本的东西,但我不知道是什么。

标签: git

解决方案


在 .git 目录中添加一个文件。那是一个no no


推荐阅读