将项目文件夹上传到私人 git 仓库中的特定位置(子文件夹)
Upload project folder to specific location (subfolder) in private git repo
我正在尝试使用终端将项目文件夹上传到私人存储库的特定位置,但我遵循的过程似乎不起作用。特别是,我要上传文件的文件夹有以下路径:
https://github.com/username/repo_name/tree/master/folder_where_I_want_to_upload_another_folder
我尝试在本地文件夹中执行以下操作:
git init
git add .
git commit -m "my commit"
git remote add origin <remote repository folder URL>
git push origin master
知道如何解决这个问题吗?
我处理这个问题的方法是首先使用
克隆 repo
git clone https://github.com/username/repo_name.git
然后从这里开始,如果 folder_where_I_want_to_upload_another_folder
不存在,您需要创建它。在此处添加您要上传的 files/folders。
如果您只想上传一个空文件夹,则不能。来自 git FAQs :
Currently the design of the Git index (staging area) only permits files to be listed, and nobody competent enough to make the change to allow empty directories has cared enough about this situation to remedy it.
Directories are added automatically when adding files inside them. That is, directories never have to be added to the repository, and are not tracked on their own.
You can say "git add " and it will add the files in there.
If you really need a directory to exist in checkouts you should create a file in it. .gitignore works well for this purpose (there is also a tool MarkEmptyDirs using the .NET framework which allows you to automate this task); you can leave it empty or fill in the names of files you do not expect to show up in the directory.
现在知道了这一点,添加一个空文件夹 .gitignore
或者,我更喜欢的是添加一个自述文件,解释拥有一个空文件夹的目的。
然后从 repo 的根开始,运行
git add folder_where_I_want_to_upload_another_folder
git commit -m "Added files and folders"
git push origin master
我正在尝试使用终端将项目文件夹上传到私人存储库的特定位置,但我遵循的过程似乎不起作用。特别是,我要上传文件的文件夹有以下路径:
https://github.com/username/repo_name/tree/master/folder_where_I_want_to_upload_another_folder
我尝试在本地文件夹中执行以下操作:
git init
git add .
git commit -m "my commit"
git remote add origin <remote repository folder URL>
git push origin master
知道如何解决这个问题吗?
我处理这个问题的方法是首先使用
克隆 repogit clone https://github.com/username/repo_name.git
然后从这里开始,如果 folder_where_I_want_to_upload_another_folder
不存在,您需要创建它。在此处添加您要上传的 files/folders。
如果您只想上传一个空文件夹,则不能。来自 git FAQs :
Currently the design of the Git index (staging area) only permits files to be listed, and nobody competent enough to make the change to allow empty directories has cared enough about this situation to remedy it.
Directories are added automatically when adding files inside them. That is, directories never have to be added to the repository, and are not tracked on their own.
You can say "git add " and it will add the files in there.
If you really need a directory to exist in checkouts you should create a file in it. .gitignore works well for this purpose (there is also a tool MarkEmptyDirs using the .NET framework which allows you to automate this task); you can leave it empty or fill in the names of files you do not expect to show up in the directory.
现在知道了这一点,添加一个空文件夹 .gitignore
或者,我更喜欢的是添加一个自述文件,解释拥有一个空文件夹的目的。
然后从 repo 的根开始,运行
git add folder_where_I_want_to_upload_another_folder
git commit -m "Added files and folders"
git push origin master