Commit changes only in one directory in Git
I'm using Git 1.7.4.1 on Mac 10.6.6. From the command line, how do I commit changes in only a single directory? I added the directory by doing:
git add my-dir
but doing
git commit -a
brings up a list of all changes in my repo, and I only want to commit and push changes from my-dir
.
Omit the -a
option. Then git
will commit only the files that you staged with git add
.
You can also try committing the directory without staging with git commit my-dir
.
Why does no one mention you can simply
git commit -m 'message' -- my-dir
It seems to me the OP isn't used to / doesn't like to use the staging area directly. This approach is also a lot safer to recommend without further context, because chances are that a defaault commit (of everything that's staged) will
Hmm, odd. The following should work. Assuming you have nothing staged.
git add my-dir
git commit -m "Commiting first revision of my-dir folder. Very exciting feature!"
git push origin master
链接地址: http://www.djcxy.com/p/23210.html
上一篇: 各种Google App Engine数据存储操作的基准?
下一篇: 仅在Git中的一个目录中提交更改