Why does 'git commit' not save my changes?

前端 未结 12 1534
星月不相逢
星月不相逢 2020-11-29 15:16

I did a git commit -m \"message\" like this:

> git commit -m \"save arezzo files\"
# On branch master
# Changes not staged for commit:
#   (u         


        
相关标签:
12条回答
  • 2020-11-29 15:42

    You could have done a:

    git add -u -n
    

    To check which files you modified and are going to be added (dry run: -n option), and then

    git add -u
    

    To add just modified files

    0 讨论(0)
  • 2020-11-29 15:47

    You should do:

    git commit . -m "save arezzo files"
    
    0 讨论(0)
  • 2020-11-29 15:47

    I copied a small sub project I had that was under Git source control into another project and forgot to delete the .git folder. When I went to commit I got the same message as above and couldn't clear it until I deleted the .git folder.

    It is a bit silly, but it is worth checking you don't have a .git folder under the folder that doesn't commit.

    0 讨论(0)
  • 2020-11-29 15:48

    You didn't add the changes. Either specifically add them via

    git add filename1 filename2
    

    or add all changes (from root path of the project)

    git add .
    

    or use the shorthand -a while commiting:

    git commit -a -m "message".
    
    0 讨论(0)
  • 2020-11-29 15:48

    Maybe an obvious thing, but...

    If you have problem with the index, use git-gui. You get a very good view how the index (staging area) actually works.

    Another source of information that helped me understand the index was Scott Chacons "Getting Git" page 259 and forward.

    I started off using the command line because most documentation only showed that...

    I think git-gui and gitk actually make me work faster, and I got rid of bad habits like "git pull" for example... Now I always fetch first... See what the new changes really are before I merge.

    0 讨论(0)
  • 2020-11-29 15:50

    if you have more files in my case i have 7000 image files when i try to add them from project's route folder it hasn't added them but when i go to the image folder everything is ok. Go through the target folder and command like abows

    git add .
    git commit -am "image uploading"
    git push origin master
    

    git push origin master Enumerating objects: 6574, done. Counting objects: 100% (6574/6574), done. Delta compression using up to 4 threads Compressing objects: 100% (6347/6347), done. Writing objects: 28% (1850/6569), 142.17 MiB | 414.00 KiB/s

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