Git添加所有子目录 [英] Git add all subdirectories

查看:1223
本文介绍了Git添加所有子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将文件夹及其所有子目录添加到我的git存储库中。我意识到这是一个非常受欢迎的问题,做了一些谷歌搜索,我已经尝试了每个建议没有运气,特别是来自关于git-add的手册页。我甚至试过 git add -A ,但没有成功。为了简单起见,说我初始化我的git存储库为 Dir1 。然后我有以下目录结构的文件。

  Dir1 / file1-1.txt 
Dir1 / file1-2 .txt
Dir1 / Dir2 / file2-1.txt
Dir1 / Dir2 / Dir3 / file3-1.txt

我的真实文件具有5-6层深的子目录,因此是否有git命令将每个子目录中的所有文件添加到存储库?现在,当我通过手册页 git add Dir1 / \ * ,我可以看到 Dir2 中的建议我的回购,但它显示为绿色文件夹,我无法打开它,这导致我相信 Dir2 中的所有文件/文件夹没有被添加。任何帮助将不胜感激。我是一个新的git用户(不到一个星期的使用它),所以请尽量保持你的指令在初学者的水平。



  git add。 

在存储库的根目录中。它会添加一切。如果你做了 git add * ,它只会添加文件 * 点。



如果您的目录或文件在上述命令后没有添加到git index / repo中,请记住检查它是否被标记为忽​​略在 .gitignore 文件中混用。

I'm having trouble adding a folder and all of it's subdirectories to my git repository. I realized this is a very popular question after doing some googling and I've tried each suggestion with no luck, specifically the suggestion from the man page on git-add. I even tried git add -A with no success. For simplicity sake, say I initialized my git repository as Dir1. Then I have the following directory structure of files.

Dir1/file1-1.txt
Dir1/file1-2.txt
Dir1/Dir2/file2-1.txt
Dir1/Dir2/Dir3/file3-1.txt

My real files have subdirectories that span 5-6 levels deep, so is there a git command to add all the files in each subdirectory to my repository? Right now, when I do the suggestion from the man page git add Dir1/\* I can see Dir2 in my repo, but it shows up as a green folder and I can't open it, which leads me to believe that all the files/folders in Dir2 did not get added. Any help would be greatly appreciated. I'm a new git user (less than a week of using it), so try and keep your instructions at a beginner's level.

解决方案

Do

git add .

while in the root of the repository. It will add everything. If you do git add * it will only add the files * points to. The single dot refers to the directory.

If your directory or file wasn't added to git index/repo after above command, remember to check if it's markded as ignored by git in .gitignore file.

这篇关于Git添加所有子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆