2

I'm on windows 10 and I'm trying to add some changes to a file to a branch.

I'm going:

git add aws_ec2_list_instances.py

And when I got git status nothing is added:

$ 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")

Doing a git add --all or git add --force gives the same result. Nothing is added!

If I list the directory aws_ec2_list_instances.py is there:

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

I'm on this version of git for windows: git version 2.24.1.windows.2

How can I solve this?

8
  • 2
    Does aws_ec2_list_instances.py have any changes? What do you see when you run git diff -- aws_ec2_list_instances.py? Commented Dec 18, 2019 at 21:54
  • 1
    Either aws_ec2_list_instances.py is the same as what is already committed or it is listed in .gitignore. Commented Dec 18, 2019 at 21:54
  • It's not listed in git ignore. And there are definitely changes to the file. I'm even adding arbitrary changes just to be sure. git add aws_ec2_instances.py does nothing when I do a git status. Commented Dec 18, 2019 at 21:59
  • 1
    There are seven paths listed in your git status output, four under changes not staged for commit and three under untracked files. None of these seven exactly match the string aws_ec2_list_instances.py. So I would not expect git add to do anything here. Separately: You can view what's in the index (ALL of it, it will be very long in most cases) with git ls-files, or git ls-files --stage or git ls-files --debug for extra detail. Commented Dec 18, 2019 at 22:22
  • You might also try git show HEAD:./aws_ec2_list_instances.py to see what's in that copy of the file, if it exists at all, and git show :./aws_ec2_list_instances.py to see what's in the index copy of the file, if it exists at all. My guess is that both files exist and are identical to each other and to the copy in ./aws_ec2_list_instances.py. Commented Dec 18, 2019 at 22:24

2 Answers 2

1

The file has changed. I tried putting in print('Test')` in the file and copied it several times and saved it.

Then you have tried to modified a different aws_ec2_list_instances.py, in a different path.
Double-check your editor (VSCode?) and see if:

  • the path is correct
  • the case is correct
  • it is able to actually save the file (which might refuse new modification if its handle is used by another Windows process)
Sign up to request clarification or add additional context in comments.

Comments

0

Your file name doesn't seem to match the file names that needed to be added. If you want to add all your changes then just use git add . command

I would recommend installing github desktop. It is easy and more convenient to use than using the command line.

1 Comment

Your first statement is correct, but the underlying issue is probably not that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.