[英]GIT - Merge an existing local copy with cloned copy
Here is what happened. 这是发生了什么事。 My friend created a project and handed it to me.
我的朋友创建了一个项目并将其交给我。 I created the repo and started work on the project.
我创建了仓库,并开始了该项目的工作。 He also started working on the project before I was able to get him setup with git so all changes he made are independent of git.
在我能够使用git进行安装之前,他还开始从事该项目,因此他所做的所有更改都与git无关。 Is there any way he can merge his changes into the existing repo?
他有什么方法可以将自己的更改合并到现有回购中?
Say you have the two repositories: base
being the one you worked on and cloned
being the one that is independent of git. 假设您有两个存储库:
base
是您处理过的存储库, cloned
的是独立于git的存储库。 Assuming you have some remote server to collaborate together on these branches, the simplest way would be initializing git on cloned
and merging that new git repo into your base
repo (works the same as if they were two branches in one repo). 假设您有一些远程服务器在这些分支上进行协作,最简单的方法是在
cloned
git上初始化git并将新的git repo合并到您的base
repo中(工作原理就像它们是一个repo中的两个分支一样)。
On cloned
: 在
cloned
:
git init
git add .
git commit -m "Initial commit"
git remote add origin [url-to-remote]
git push origin master
On base
: 在
base
:
git remote add cloned [url-to-remote]
git fetch cloned
git merge cloned/master
# resolve any conflicts and commit if necessary
the preceding steps assumed you were just working on a singular master
branch 前面的步骤假定您只是在单个
master
分支上工作
He could do this: 他可以这样做:
clone your repository into a new directory 将您的存储库克隆到新目录
create a new branch off the initial commit and switch to it 从初始提交创建一个新分支并切换到该分支
copy his changes into the working directory of his clone 将他的更改复制到克隆的工作目录中
commit the changes 提交更改
At that stage he'll be in the state he would have been in had he been developing in Git from the start and can merge the branch back into master
, etc. 在那个阶段,如果他从一开始就在Git中进行开发,并且可以将分支合并回
master
等,那么他将处于原本的状态。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.