简体   繁体   English

如何将本地文件夹合并到现有的 git 存储库中?

[英]How to incorporate local folder into an existing git repo?

Alright so I have local folder training , that contains a bunch of scripts.好吧,我有本地文件夹training ,其中包含一堆脚本。 Also, my group has a repo on git, where I should incorporate my folder.此外,我的小组在 git 上有一个 repo,我应该将我的文件夹合并到那里。 I did some research and found the following:我做了一些研究,发现以下内容:

git init
git add <folder1> <folder2> <etc.>
git commit -m "Your message about the commit"
git remote add origin https://github.com/yourUsername/yourRepository.git
git push -u origin master
git push origin master

Unfortunately I don't have the url at the moment, but I already cloned the repository with git clone .不幸的是,我目前没有 url,但我已经使用git clone克隆了存储库。 What can I do?我能做什么?

You have 2 options for creating local git repository.您有 2 个选项来创建本地 git 存储库。

  1. As you added on your question, you can use git init which creates a local repository on your computer, which you can later push to github server using git remote .正如您在问题中添加的那样,您可以使用git init在您的计算机上创建一个本地存储库,稍后您可以使用git remote将其推送到 github 服务器。

  2. The second option, which is the one you used (without knowing) is cloning a project from github using git clone , which import the remote project onto your local machine.第二个选项,即您使用的(不知道)是使用git clone从 github 克隆一个项目,它将远程项目导入到您的本地机器上。 Later, after adding to your local project, you can use git add <folder> , git commit -m "adding <folder>" and git push to send the folder to github servers.稍后,添加到本地项目后,您可以使用git add <folder>git commit -m "adding <folder>"git push将文件夹发送到 github 服务器。 This is what you should do in your case.这是你应该在你的情况下做的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM