开发者

Merging two folders using git

I'm working on a project with some people who have never used git before. Not knowing the capabilities of git, they created two version of the project: development and production. These two versions are both present in the current environment.

To complicate things further, this other user created t开发者_运维百科hese folders in addition to the old development folder. So the project directory looks like this

/root
  /.git
  /proj         (old dev folder with my own code in it)
  /dev_proj     (new folder which I would like to merge /prod with)
  /prod_proj       (production code)

So what I'd like to do is merge the work that I've done in /proj with the work in the /dev_proj. Is there a way to do this with git?

I've thought about creating a branch, copying all the files from /proj to /dev_proj and merging that branch with master. Would this work?

Thanks and if I could clarify something let me know.


I'm not a git expert, but I would suggest making a new branch, rooted at the change where he copied his code from before making the changes.

git branch devProjTemp <commit-id>

(Don't forget to git checkout devProjTemp.) Then copy all the files from dev_proj to proj, and commit. Then you should be able to merge from the new branch to master and it should do the right thing.

If you want to have separate dev and prod data, I would also suggest creating a branch for one of them. Specifically, I would create a prod branch and copy the changes from prod_proj over to that.

Then, I would delete prod_proj and dev_proj in the master branch and the prod branch.

Does your coworker not know about branches? I would do some teaching there. It shouldn't be so hard once you've created the branches.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜