如何将目录提交到 git 存储库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1573883/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to commit a directory into a git repository?
提问by wishi
I read the great git tutorialhere, I'm unable to create directories.
我在这里阅读了很棒的git 教程,但我无法创建目录。
My folder structure is:
我的文件夹结构是:
Code - Python - C++ - F# - ...
代码 - Python - C++ - F# - ...
From within a initialised local repository "Code" I changed into the subfolders "Python", "C++", ... did git init
and now I want the same structure on my versioning server.
从初始化的本地存储库“代码”中,我更改为子文件夹“Python”、“C++”、...做了git init
,现在我想要在我的版本控制服务器上使用相同的结构。
% git commit -m "added directories"
# On branch master
nothing to commit (working directory clean)
I guess I got something completely wrong, did I?
我想我完全错了,是吗?
Thanks, wishi
谢谢,希望
回答by Juha Syrj?l?
Try to add some files to directories first. You can add some dummy file to directory, and remove that file when you have added the actual content for the directory.
尝试先将一些文件添加到目录中。您可以向目录添加一些虚拟文件,并在为目录添加实际内容后删除该文件。
Git does not track empty directories, it tracks files and their contents.
Git 不跟踪空目录,它跟踪文件及其内容。
git init
mkdir foo
touch foo/dummy_empty_file
git add foo
git add foo/dummy_empty_file
git commit -m "adding files"
回答by Marc W
Git won't commit empty directories. There must be files in the directories first.
Git 不会提交空目录。首先目录中必须有文件。