git Git项目中的子文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4866322/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 10:00:21  来源:igfitidea点击:

Sub folder in Git project?

gitgithubclone

提问by ParisNakitaKejser

I have been using Subversion for a long time and now I have switched to Git.

我已经使用 Subversion 很长时间了,现在我已经切换到 Git。

Now I need to know how to get sub folders in my Git project?

现在我需要知道如何在我的 Git 项目中获取子文件夹?

I know sombody will make 2 projects for this but I dont need 2 projects for this. I need to clone a subfolder and not my main project.

我知道有人会为此做 2 个项目,但我不需要 2 个项目。我需要克隆一个子文件夹而不是我的主项目。

I use github.com.

我使用 github.com。

采纳答案by ParisNakitaKejser

I found an answer: http://blog.quilitz.de/2010/03/checkout-sub-directories-in-git-sparse-checkouts/

我找到了一个答案:http: //blog.quilitz.de/2010/03/checkout-sub-directories-in-git-sparse-checkouts/

I had git 1.5.5, and it requires 1.7+; now I have 1.7 and it's all working fine. :) But thanks a lot for the answer.

我有 git 1.5.5,它需要 1.7+;现在我有 1.7 并且一切正常。:) 但是非常感谢您的回答。

回答by ThiefMaster

When cloning a git repository you always clone the whole repository.

克隆 git 存储库时,您总是克隆整个存储库。

If you want subfolders in your project simply create them though. As soon as you add files inside them (git only tracks files no folders -> if a folder is empty you cannot add it to your repo), they can be committed to your repository by committing the files inside.

如果您想要项目中的子文件夹,只需创建它们即可。一旦您在其中添加文件(git 只跟踪文件而不跟踪文件夹 -> 如果文件夹为空,则无法将其添加到您的存储库中),它们可以通过提交其中的文件来提交到您的存储库。

回答by Yuming Cao

  1. create a folder
  2. "git add" this folder
  3. "git commit -m 'message'"
  4. "git push"
  1. 创建文件夹
  2. “git add”这个文件夹
  3. “git commit -m '消息'”
  4. “git push”

DONE!

完毕!

回答by Ho1

Yes, you can! Github also provides SVN access for repositories. For example I want to get Android fonts here:
https://github.com/android/platform_frameworks_base/tree/master/data/fonts
Just run this command, see the pattern, replace /tree/master with /trunk:

是的你可以!Github 还为存储库提供 SVN 访问。例如,我想在这里获取 Android 字体:
https: //github.com/android/platform_frameworks_base/tree/master/data/fonts
只需运行此命令,查看模式,将 /tree/master 替换为 /trunk:

svn checkout https://github.com/android/platform_frameworks_base/trunk/data/fonts

回答by Keenal

You won't be able to add an empty folder. Create a file first, add a folder inside it and then link the file inside the folder. Similarly, once you have a main folder, you can add files or create subfolders inside this folder.

您将无法添加空文件夹。首先创建一个文件,在其中添加一个文件夹,然后将文件夹中的文件链接起来。同样,拥有主文件夹后,您可以在该文件夹中添加文件或创建子文件夹。