如何将新文件夹(包含其他文件夹和文件)推送到现有的 git 存储库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15612003/
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
How to push a new folder (containing other folders and files) to an existing git repo?
提问by da32
I cloned a repository to my desktop machine using git clone sshurl
. As expected, this created a folder in my desktop.
我使用git clone sshurl
. 正如预期的那样,这在我的桌面上创建了一个文件夹。
Now, instead of a single file, I want to push a whole folder into git. For example, the folder that I cloned is named project_iphone
. Now I add another folder called my_project
into project_iphone
. The my_project
folder contains lots of files and folders as well.
现在,我想将整个文件夹推送到 git 中,而不是单个文件。例如,我克隆的文件夹名为project_iphone
. 现在我添加另一个名为my_project
into 的文件夹project_iphone
。该my_project
文件夹还包含许多文件和文件夹。
My question is, how should I push my_project
folder to the server?
我的问题是,我应该如何将my_project
文件夹推送到服务器?
Step-by-step instructions would be helpful.
分步说明会很有帮助。
Thank You.
谢谢你。
回答by Gavin
You need to git add my_project
to stage your new folder. Then git add my_project/*
to stage its contents. Then commit what you've staged using git commit
and finally push your changes back to the source using git push origin master
(I'm assuming you wish to push to the master branch).
您需要git add my_project
暂存您的新文件夹。然后git add my_project/*
上演它的内容。然后提交您使用的暂存内容git commit
,最后使用git push origin master
(我假设您希望推送到主分支)将您的更改推送回源。