1

I have three different versions of a program, and now, much too late, I would like to move it into a git repository.

Would it be possible to start a repository with the live environment and add the test and development environment each into a branch?

rayphi
  • 503
  • 2
  • 14
  • 30

1 Answers1

2

Yes: you can git init, add and commit in the live environment, then you can create the relevant branches (still from the live environment where your repo resides):

git checkout -b dev
git --work-tree=/path/to/dev add .
git commit -m "dev"

git checkout master
git checkout -b test
git --work-tree=/path/to/tes add .
git commit -m "test"

From there, it is best to clone (git clone --mirror) that repo elsewhere, as a bare repo, and manage the update of your live, test and dev environments through post-receive hook.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • thanks for the fast reply. And to get things a bit crazier what if the three environments are on three different servers? – rayphi Mar 03 '15 at 08:16
  • @rayphi then you would need to bundle the repo and copy it around: http://stackoverflow.com/a/28522093/6309 – VonC Mar 03 '15 at 08:29
  • I am right, I have to generate the bundle on each change in any brach and copy it around? That sounds complicated. Is there not an easier way? Is it possible to do something like Create a git repository on my git server (server A) and declare on Server (B,C & D) dev, test and prod as branches and push them to the "origin" repository on server A – rayphi Mar 03 '15 at 13:28
  • 1
    @rayphi yes, if you have a shared folder enabling an UNC path (http://en.wikipedia.org/wiki/Path_%28computing%29#Uniform_Naming_Convention) or posix shared path access (or if you have ssh access), you can directly push/pull from those servers between repos. – VonC Mar 03 '15 at 13:35