开发者

How can I merge remote and local changes in my copied repository?

开发者 https://www.devze.com 2023-03-05 13:14 出处:网络
I did something silly. I was in a hurry and needed my code on my laptop, so I copied my entire development directory from my desktop to my laptop, using a USB drive.

I did something silly. I was in a hurry and needed my code on my laptop, so I copied my entire development directory from my desktop to my laptop, using a USB drive.

Anyways the development directory contained a git project which has had several commit开发者_StackOverflows pushed by others since I last pulled. Problem is I have made changes to the code on my laptop and to make things worse, my desktop PC has had a drive failure. My laptop does not even have git (yet), and I cannot transfer the files to my PC and then merge with the new code.

Once I have git installed, what should I do?


It's not really a huge disaster at all since git is designed to handle this type of thing. You just have to keep in mind that effectively you've created just another repository. It's hard to give concrete advice without more detail on what changes have been made, but through the judicious use of branching, cherry-picking commits etc, it should be a relatively painless process to resolve (although it may take time).

Depending on your skill level with git, for instance if you're relatively new, this could seem to be an insurmountable challenge. I recommend you do read up on how to perform cherry-picking, branching and merging, how to push to a remote repository (and also how to add additional remotes) etc, as you'll probably need to do a fair bit of the above. You should be able to effectively treat each repository as a discrete entity and push and pull between them to get them in sync (although, really it seems like you only want to be pulling changes from one to form your main repo and get it up to date before pushing and pulling to other dev repo's again).

There are some great resources on the web that can be found with some quick googling.

Without more information it's difficult to say what could be involved.

As a suggestion to get started, it's probably going to be easiest if you put the two repositories together on the one machine (put them in separate directories, you don't want to accidentally copy one over the other). Then on that same machine, in your "main" repository set up a remote pointing to the other repository you'd like to pull changes from, it's probably best to then perform a 'git fetch' to get the remote branches and head to begin the merging process manually (rather than performing a pull and having everything merge automatically, which might not be something you want to happen). Once you've done that, you can then cherry-pick and/or merge at your leisure.


Once you have git installed, all you need to do is to pull in the new changes so you can merge them with yours. That's it.

0

精彩评论

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