简体   繁体   English

如何在目录库中添加目录树?

[英]How can I add a directory tree to my github repo?

I've been working on a project that's fairly far a long now and I decided it's time to use some sort of version control etc. I decided to go with github. 我一直在从事一个相当长的项目,所以我决定该使用某种版本控制等了。我决定使用github。 Before I get in too deep let me state explicitly that I am new to github. 在深入之前,请先明确声明我是github的新手。

My project resides in a directory that contains myriad subdirectories and files of all different kinds. 我的项目驻留在一个目录中,该目录包含无数子目录和各种不同类型的文件。 I'd like to take my project directory as is (structure and all) and put it in my github repo. 我想按原样(结构和全部)保存项目目录,并将其放在我的github存储库中。

I followed the tutorials on github's webpage, created the repo, and manually added some files. 我按照github网页上的教程进行操作,创建了存储库,并手动添加了一些文件。 Obviously I don't want to manually add every file (there are several hundred). 显然,我不想手动添加每个文件(有几百个)。 I'd like to know how I can add the root directory or for that matter any parent directory and all files/folders in said said directory. 我想知道如何添加根目录,或者说任何父目录以及所述目录中的所有文件/文件夹。 In other words I'm looking for a recursive add. 换句话说,我正在寻找一个递归添加。

I read on this SO page ( How to create folder in github repository? ) that you can just use 我在这个SO页面( 如何在github仓库中创建文件夹? )上读到了,您可以使用

git add directory/

That works fine for me when I'm dealing with the lowest level directory, but when I try the same command on a directory with subdirectories my terminal just sits there and I have to ctrl-c. 当我处理最低级别的目录时,这对我来说很好,但是当我在具有子目录的目录上尝试相同的命令时,我的终端就坐在那儿,我必须使用ctrl-c。 I can't tell if it's just taking a long time (as I mentioned there are lots of files) or if this is just the wrong way to add a directory with subdirectories. 我不能说这是否花了很长时间(正如我提到的,有很多文件),或者这只是添加带有子目录的目录的错误方法。

Apologies in advance if this is a super ignorant question -- I have looked at a lot of blogs/posts/etc and I cannot find a solution that seems to work. 如果这是一个非常无知的问题,请事先道歉-我看了很多博客/帖子/等,但找不到适合的解决方案。

Use the Current Working Directory 使用当前工作目录

Assuming you're on Linux or OS X, from the command line you would do the following: 假设您使用的是Linux或OS X,请从命令行执行以下操作:

git add .

from the root of your repository tree. 从存储库树的根目录开始。 That will add all non-ignored files, including non-empty directories, into the repository. 这会将所有非忽略文件(包括非空目录)添加到存储库中。

From the root directory (the one with all the subdirectories), use git add -A . 在根目录(包含所有子目录的目录)中,使用git add -A

If you have a ton of subdirectories and files, it may take a long while, so just let it sit there until it's done. 如果您有大量的子目录和文件,则可能要花很长时间,因此只需坐在那里直到完成即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM