Can I copy one git repositories commit log to an (almost) identical repo with no history?

Go To StackoverFlow.com

2

I'm currently working on a modification of a big e-commerce platform

A large amount of initial development had been done before started on the project, and none of it was under any version control, so I have no file history.

In order to build a picture of all the previous work that had been done, I started with a clean install of the platform, and merged in all the previous changes bit by bit under git version control.

I now have two almost identical copies of the software, one is the working development server, the other is my local repo with a change history.

I want to clone the repo onto the working copy on the server, without upsetting what is already there.

I don't like the idea of wiping the dev server and cloning my local repository. Is there a better way?

2012-04-04 23:17
by chrisj
I thought you only had one git repo, so there's two with different history? Or one repo with history and another folder with a bunch of files in it - ralphtheninja 2012-04-04 23:24
That is actually more accurate, thanks, I'll edit above to clarify.

I guess what I need to do is clone the repo, with history, without upsetting the working copy on the server - chrisj 2012-04-05 00:07



0

You can go to the development server and run git init to turn the root there into a git repo. At this point, you can push your changes to it (or have it pull from somewhere else, which is probably the better route), which will give it access to the history you've built. Assuming at this point that the history is in origin/master, you can now do something like git branch master origin/master to create a master branch based on this history. And finally, you can run git reset master to bring HEAD up on your new master without modifying the working copy.

At this point, since you said they were only nearly identical, your development server should now be running on top of git, with uncommitted changes representing the differences between the dev server's version and your newly-constructed version.

2012-04-05 00:15
by Lily Ballard
Thanks! I'll give this a go and report back - chrisj 2012-04-05 00:18
Ok, I have an issue here. I can't pull onto the dev server, so I'm left with the push option from my repo. When I attempt to push I get a "refusing to update checked out branch" error. Should I set to ignore for recieve.denyCurrentBranch, or is there something I'm missing - chrisj 2012-04-05 11:43
@chrisj: You should probably set up a separate bare repo that you can push to, and then pull from there onto your actual deployment repo - Lily Ballard 2012-04-05 19:03
now I feel silly that I didn't think of that. Cheers - chrisj 2012-04-05 20:12


0

You could clone the repo into a bare one.

git clone --bare /path/to/repo.git

This will create a repository named "repo.git", which is a bare repository folder. You can copy this folder into /path/to/devserver/, e.g.

mv repo.git /path/to/devserver/.git

Now you have the repository and the devserver files on the same place. If you type git status you are going to see that some files are changed etc. If you stage everything as it is and commit it, you will have the old history + one commit that's the diff between your original repo and the current development server code.

2012-04-05 00:16
by ralphtheninja
Cloning into a bare repo and then moving it won't work quite right, because the bare repo will have core.bare set to true (and possibly some other config settings that non-bare repos don't get) - Lily Ballard 2012-04-05 00:21
Ads