You will commit any changes in the "staging area"; you can see these with git status
.
the -a
flag in git commit -a
, according to the man page, tells git to roughly "stage all files that have been modified or deleted, but not new files you have not told git about" - this is not what you want
the lesson is to be aware of what command line options do
To fix this, the first thing you want to do is, according to How to undo 'git add' before commit? , to unstage all the files you've accidentally added with the commit -a
option. According to that answer, you must perform the command git rm -r --cached .
, and now your changes should still be there, but nothing is staged.
Now you can do git add my-dir
like you did before. Then you can do git commit
(WITHOUT THE -a
)