Same files listed as both untracked and deleted

后端 未结 2 1524
逝去的感伤
逝去的感伤 2021-01-12 11:16

Running git status in a Git repository, I get:

Changes not staged for commit:
  (use \"git add/rm ...\" to update what will be commi         


        
2条回答
  •  长发绾君心
    2021-01-12 11:35

    I had a very similar problem, discussed here Git doesn't stage my files any longer, and reports them as both "deleted" and "untracked". Why is that, and how to avoid it?

    I found that :

    • Using git add --all worked fine to stage

    • Using git add -A did not work... even if it is supposed to be equivalent to the first

    • Putting blank space may have been your problem, but it was not what caused mine :( it remains unresolved. FYI, I am working on Mac OS 10.10

    • I still have the problem any time I add my file with the simple command git add filename (without space), and still resolve it by adding everything (git add --all) So it is a little bit of a hassle (for both being not handy, and remaining unexplained) but still I can go on with my work.

    Here is the illustration of what worked, what did not, what recreated the problem, and what solved it back:

    $ git add --all
    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    Changes to be committed:
      (use "git reset HEAD ..." to unstage)
    
        modified:   Challenge28.py
        modified:   ch28_NN.py
    
    $ git add Challenge28.py
    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    Changes to be committed:
      (use "git reset HEAD ..." to unstage)
    
        deleted:    .gitignore
        modified:   Challenge28.py
        deleted:    ch28_NN.py
        deleted:    requirements.txt
    
    Untracked files:
      (use "git add ..." to include in what will be committed)
    
        .gitignore
        ch28_NN.py
        requirements.txt
    
    $ git add --all
    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    Changes to be committed:
      (use "git reset HEAD ..." to unstage)
    
        modified:   Challenge28.py
        modified:   ch28_NN.py
    
    $ git add Challenge28.py
    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    Changes to be committed:
      (use "git reset HEAD ..." to unstage)
    
        deleted:    .gitignore
        deleted:    Challenge28.py
        deleted:    ch28_NN.py
        deleted:    requirements.txt
    
    Untracked files:
      (use "git add ..." to include in what will be committed)
    
        .gitignore
        Challenge28.py
        ch28_NN.py
        requirements.txt
    
    $ git add -A
    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    Changes to be committed:
      (use "git reset HEAD ..." to unstage)
    
        deleted:    .gitignore
        deleted:    Challenge28.py
        deleted:    ch28_NN.py
        deleted:    requirements.txt
    
    Untracked files:
      (use "git add ..." to include in what will be committed)
    
        .gitignore
        Challenge28.py
        ch28_NN.py
        requirements.txt
    
    $ git add --all
    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    Changes to be committed:
      (use "git reset HEAD ..." to unstage)
    
        modified:   Challenge28.py
        modified:   ch28_NN.py
    

提交回复
热议问题