我在Mac 10.6.6上使用Git 1.7.4.1.从命令行,如何仅在单个目录中提交更改?我通过这样做添加了目录:
git add my-dir
Run Code Online (Sandbox Code Playgroud)
但是做
git commit -a
Run Code Online (Sandbox Code Playgroud)
显示我的仓库中所有更改的列表,我只想提交并推送更改my-dir.
seh*_*ehe 56
为什么没有人提到你可以简单
git commit -m 'message' -- my-dir
Run Code Online (Sandbox Code Playgroud)
在我看来OP不习惯/不喜欢直接使用临时区域.这种方法在没有进一步背景的情况下推荐也更安全,因为可能是违约提交(已经上演的所有内容)
ral*_*nja 14
嗯,奇怪.以下应该有效.假设你什么都没有上演.
git add my-dir
git commit -m "Commiting first revision of my-dir folder. Very exciting feature!"
git push origin master
Run Code Online (Sandbox Code Playgroud)
小智 9
基本
git add -- ./myfolder
git commit -m'my comment' -- ./myfolder
Run Code Online (Sandbox Code Playgroud)
有更多的文件和目录
git add -- ./myfolder1 ./myfolder2./some/random/file.txt
git commit -m'cool' -- ./myfolder1 ./myfolder2 ./some/random/file.txt
Run Code Online (Sandbox Code Playgroud)
我正在寻找git bare repo
git --git-dir=path/to/my/repo --work-tree=path/to/my/working/tree add -- ./myfolder
git --git-dir=path/to/my/repo --work-tree=path/to/my/working/tree commit -m'my comment' -- ./myfolder
Run Code Online (Sandbox Code Playgroud)
记得用空格或疯狂的字符引用路径