简体   繁体   English

将git文件夹从本地计算机移动到现有存储库-包括提交历史记录

[英]moving a git folder from local computer to an existing repo - commit history included

I'm trying to move a folder (let's call it "projectA") I've started with git version control in local computer- it has not repo connected 我正在尝试移动一个文件夹(我们称它为“ projectA”),我已经在本地计算机上开始使用git版本控制了-它没有回购连接

I would like to move "projectA" along with its history commit to a new repo called projectB. 我想将“ projectA”及其历史记录一起移到一个名为projectB的新存储库中。

projectA - this is stored in local computer and has no github repo
  app

projectB
  folder1
  folder2
  projectA - 'final destination'

So far I understand I have to do git clone for projectB, but after that I don't know to transfer projectA with its history commit under ProjectB. 到目前为止,我知道我必须为projectB做git clone ,但是在那之后,我不知道将其历史提交提交给ProjectA在ProjectB下进行。

Can anybody help me with this? 有人可以帮我吗? I only know the basics of git - add commit pull push. 我只知道git的基础-添加提交拉推。 Your help will be appreciated. 您的帮助将不胜感激。

In your Project A create a new branch 在您的项目A中创建一个新分支

git checkout -b project_a_work

Add remote github repo for Project B 为项目B添加远程github存储库

git remote add origin git@github.com/project_b.git

Do a git fetch and checkout project B master(any other branch you want to merge on) 做一个git fetch and check project B master(您要合并的其他任何分支)

git fetch
git checkout origin/master

Now merge the Project A work on Project B's current checkout branch 现在,将项目A的工作合并到项目B的当前结帐分支中

git merge project_a_work

OR 要么

If you want all Project A history to be written after last commit on Project B, you can do git rebase 如果要在上次提交项目B之后写入所有项目A历史记录,可以执行git rebase

git rebase project_a_work

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

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