git 如何将现有文件的本地项目导入到源树

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

How to import local project with existing files to Source tree

gittree

提问by mistery_girl

I'm using Source tree. But I have existing project folder with files in it. I want to import project folder to Source Tree. I tried to remove files from project and then add folder to Source Tree with:

我正在使用源树。但我有现有的项目文件夹,其中包含文件。我想将项目文件夹导入源树。我尝试从项目中删除文件,然后使用以下命令将文件夹添加到源树:

Clone/New

克隆/新建

After that I added my project files. But I can't commit and push my changes and it's not showing latest changes when I change file from project. I've read questions and I couldn't find in Source Tree menu :

之后我添加了我的项目文件。但是我无法提交和推送我的更改,并且当我从项目更改文件时它没有显示最新的更改。我已经阅读了问题,但在源树菜单中找不到:

Repositories > import repository

How to import my project?

如何导入我的项目?

回答by oshnaps

Seems like you're missing the .git folder. You should:

似乎您缺少 .git 文件夹。你应该:

  1. Create a new empty repository on your git client.
  2. Clone it by source tree.
  3. Copy the .git folder to your existing project folder.
  1. 在您的 git 客户端上创建一个新的空存储库。
  2. 通过源树克隆它。
  3. 将 .git 文件夹复制到您现有的项目文件夹中。

At this point source tree should alarm you that the repository local location was changed, just follow it's interface in order to change the location, and you're done.

此时,源树应该提醒您存储库本地位置已更改,只需按照它的界面更改位置即可,您就完成了。

回答by yorammi

Since this is not a git folder (it doesn't have a .git sub-folder in its root folder), you just need to do the following (in command line):

由于这不是 git 文件夹(它的根文件夹中没有 .git 子文件夹),您只需要执行以下操作(在命令行中):

cd root-folder
git init