What does “Changes not staged for commit” mean

前端 未结 9 1991
再見小時候
再見小時候 2021-01-29 17:17

I thought if you want to track the files you should git add [files you want to track]

I don\'t know why I got the messages Changes not staged for com

相关标签:
9条回答
  • 2021-01-29 18:07

    when you change a file which is already in the repository, you have to git add it again if you want it to be staged.

    This allows you to commit only a subset of the changes you made since the last commit. For example, let's say you have file a, file b and file c. You modify file a and file b but the changes are very different in nature and you don't want all of them to be in one single commit. You issue

    git add a
    git commit a -m "bugfix, in a"
    git add b
    git commit b -m "new feature, in b"
    

    As a side note, if you want to commit everything you can just type

    git commit -a
    

    Hope it helps.

    0 讨论(0)
  • 2021-01-29 18:07

    Suposed you saved a new file changes. (navbar.component.html for example)

    Run:

    ng status
    modified:   src/app/components/shared/navbar/navbar.component.html
    

    If you want to upload those changes for that file you must run:

    git add src/app/components/shared/navbar/navbar.component.html
    

    And then:

    git commit src/app/components/shared/navbar/navbar.component.html -m "new navbar changes and fixes"
    

    And then:

    git push origin [your branch name, usually "master"]
    

    ---------------------------------------------------------------

    Or if you want to upload all your changes (several/all files):

    git commit -a
    

    And them this will appear "Please enter the commit message for your changes."

    • You'll see this message if you git commit without a message (-m)
    • You can get out of it with two steps:
    • 1.a. Type a multi-line message to move foward with the commit.
    • 1.b. Leave blank to abort the commit.
      1. Hit "esc" then type ":wq" and hit enter to save your choice. Viola!

    And then:

    git push
    

    And Viola!

    0 讨论(0)
  • 2021-01-29 18:15

    Remove dir/.../.git

    works for me.

    0 讨论(0)
提交回复
热议问题