git忽略了';git add';命令';

git忽略了';git add';命令';,git,Git,我使用的是windows 10,我正在尝试将一些更改添加到分支的文件中 我要去: git add aws_ec2_list_instances.py 当我获得git状态时,没有添加任何内容: $ git status On branch python Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <f

我使用的是windows 10,我正在尝试将一些更改添加到分支的文件中

我要去:

git add aws_ec2_list_instances.py
当我获得git状态时,没有添加任何内容:

$ git status
On branch python
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   __pycache__/web_scraper.cpython-37.pyc
        modified:   __pycache__/web_scraper.cpython-38.pyc
        modified:   aws_s3_list_buckets.py
        modified:   web_scraper.py

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        ../../output_files/
        aws_ec2_list_instances_old.py
        ../../source_files/

no changes added to commit (use "git add" and/or "git commit -a")
我使用的是git for windows的这个版本:
git版本2.24.1.windows.2


如何解决此问题?

您的文件名似乎与需要添加的文件名不匹配。如果要添加所有更改,只需使用
git add.
命令

我建议安装github桌面。它比使用命令行更容易、更方便

文件已更改。我试着在文件中输入print('Test')`并复制了几次并保存了它

然后您尝试在不同路径中修改不同的aws_ec2_list_instances.py。
仔细检查编辑器(VSCode?),看看是否:

  • 这条路是正确的
  • 情况是正确的
  • 它能够实际保存文件(如果它的句柄被另一个Windows进程使用,可能会拒绝新的修改)

  • aws\u ec2\u list\u instances.py
    是否有任何更改?运行
    git diff--aws_ec2_list_instances.py
    时,您会看到什么?要么
    aws_ec2_list_instances.py
    与已提交的内容相同,要么在
    .gitignore
    中列出。它不在git ignore中列出。而且文件肯定有变化。我甚至添加了任意的更改,只是为了确定
    git add aws_ec2_instances.py
    在我执行git状态时不执行任何操作。在您的
    git状态
    输出中列出了七条路径,在
    未提交的更改下有四条路径,在
    未跟踪的文件下有三条路径。这七个实例中没有一个与字符串
    aws\u ec2\u list\u instances.py
    完全匹配。所以我不希望git add在这里做任何事情。单独:您可以使用
    git ls文件
    ,或
    git ls文件--stage
    git ls文件--debug
    查看索引中的内容(所有内容,在大多数情况下都很长)。您还可以尝试
    git show HEAD:./aws_ec2_list_instances.py
    查看文件副本中的内容(如果存在的话),和
    git show:./aws_ec2_list_instances.py
    查看文件的索引副本中有什么内容(如果存在)。我猜这两个文件都存在,并且彼此相同,并且与
    /aws\u ec2\u list\u instances.py
    中的副本相同。您的第一句话是正确的,但根本问题可能不是这样。
    git ls-files
    __pycache__/web_scraper.cpython-37.pyc
    __pycache__/web_scraper.cpython-38.pyc
    aws_ec2_list_instances.py
    aws_s3_list_buckets.py
    web_scraper.py