1

私は、4 つのファイルを含む単純な git リポジトリで、何度も追加およびコミットすることに成功しています。

しかし最近、それらのいくつかを追加しようとしてステータスを尋ねると、gitはすべてのファイルを削除済みで追跡されていないと報告します。そのため、ファイルを追加できません。

$ git add 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 <file>..." to unstage)

    deleted:    .gitignore
    deleted:    Challenge28.py
    deleted:    ch28_NN.py
    deleted:    requirements.txt

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

    .gitignore
    Challenge28.py
    ch28_NN.py
    requirements.txt

私の唯一の解決策は、バックアップを作成し、リセットしてステージングを解除することです。

何がうまくいかなかったのか、それを回避する方法を理解したいと思います。

4

1 に答える 1

0

私は最終的に解決策を見つけました。これは、2 つの提案された (しかし興味深い) リンクで説明されているものではありません。

見つけた :

  • git add --allうまく機能してステージに使用

  • 使用git add -Aしても機能しませんでした...最初と同等のはずです

  • 簡単なコマンドでファイルを追加するたびに問題が発生しますが、git add filenameすべてを追加することで解決しgit add --allます (私の仕事を続けてください。

以下は、何が機能し、何が機能しなかったか、何が問題を再現し、何が問題を解決したかを示しています。

$ git add --all           # WORKED FINE
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    modified:   Challenge28.py
    modified:   ch28_NN.py

$ git add Challenge28.py           # CREATED BACK THE PROBLEM - but it deleted only three files and it staged one (an other case is reproduced below, with the same command)
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    deleted:    .gitignore
    modified:   Challenge28.py
    deleted:    ch28_NN.py
    deleted:    requirements.txt

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

    .gitignore
    ch28_NN.py
    requirements.txt

$ git add --all           # WORKED FINE AGAIN !
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    modified:   Challenge28.py
    modified:   ch28_NN.py

$ git add Challenge28.py           # CREATED BACK THE PROBLEM - but it deleted all the four files... 
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    deleted:    .gitignore
    deleted:    Challenge28.py
    deleted:    ch28_NN.py
    deleted:    requirements.txt

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

    .gitignore
    Challenge28.py
    ch28_NN.py
    requirements.txt

$ git add -A           # DID NOT WORK 
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    deleted:    .gitignore
    deleted:    Challenge28.py
    deleted:    ch28_NN.py
    deleted:    requirements.txt

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

    .gitignore
    Challenge28.py
    ch28_NN.py
    requirements.txt

$ git add --all           # WORKED FINE AGAIN...
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    modified:   Challenge28.py
    modified:   ch28_NN.py
于 2016-11-09T16:29:56.520 に答える