[英]Is it possible with Git to commit a file in a specific folder in the repository?
I'm new with git and I'm trying to use JGit in a java application. 我是git的新手,正在尝试在Java应用程序中使用JGit。 I would like to know if Git has a 'commmit of files into a specific directory' or is Git only based on the working tree where files are stored?
我想知道Git是否具有“将文件提交到特定目录中”或Git仅基于存储文件的工作树吗?
For example, let's say I have a file saved in C:/tmp/myfile.docx. 例如,假设我有一个文件保存在C:/tmp/myfile.docx中。 Is it possible to tell Git to store it in the repository as /myProject/myfile.docx ?
是否可以告诉Git将其作为/myProject/myfile.docx存储在存储库中?
Thank you :) 谢谢 :)
That is not possible. 这是不可能的。 Think of your Git repository as a time machine for a tree of directories.
将您的Git存储库想像成目录树的时间机器。 You can only add files to git that are inside that directory tree.
您只能将该目录树中的文件添加到git中。 And don't try to make C:\\ a Git repository... :)
而且不要尝试使C:\\一个Git存储库... :)
So, let's say your Git repository resides at C:\\tmp\\myRepo
. 因此,假设您的Git存储库位于
C:\\tmp\\myRepo
。 To add your file to the repository you'd do this: 要将文件添加到存储库,请执行以下操作:
myfile.docx
to C:\\tmp\\myRepo
myfile.docx
移至C:\\tmp\\myRepo
cd C:/tmp/myRepo && git add -A
cd C:/tmp/myRepo && git add -A
git commit -am "added myfile.docx"
git commit -am "added myfile.docx"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.