0

My old laptop died with my GitStack installation and local Git repositories on it. It was a hardware issue, and the hard drive wasn't affected (I have the hard drive attached to my new computer and it works with no issues). Of course, I want to install GitStack on my new computer and migrate the old repositories into the new installation. I couldn't find any documentation on this. Has anybody done this, or does anybody knowledgeable about GitStack have any advice for me?

Edit: the user poke who responded was very knowledgeable. Rather than fighting with GitStack -- which appears less supported than it used to be -- I was able to install a local Git for Windows server, and push the contents from my old hard drive as a new repository by using remotes. It worked perfectly.

  1. I installed Git for Windows according to the tutorial

  2. I created a bare repository somewhere on my disk: git clone --bare C:\Repositories\Blah.git

  3. I navigated into the repository from the disk pulled out of my old laptop

  4. The existing ./.git/config file still referenced my old GitStack local server. I removed that via git remote remove origin

  5. Now my existing repo needed to be updated to refer to the Git for Windows local server installed in step 0. The command was: git remote add origin myusername@localhost:C:/Repositories/Blah.git

  6. The Git for Windows tutorial mentioned some special configuration is presently needed for working around an issue with the current builds. In particular, the tutorial instructs you to enter these commands in your repositories:

    git config --local remote.origin.uploadpack "powershell git-upload-pack"

    git config --local remote.origin.receivepack "powershell git-receive-pack"

  7. I pushed the master branch to the origin via: git push -u origin

  8. I switched to the student branch via: git checkout student

  9. I pushed the student branch to the origin via: git push -u origin

  10. Then, to test, I created a new repository elsewhere:

git init Blah cd Blah [same commands from steps 5 and 6] git fetch git pull origin master

  1. From there I could switch between branches without having to merge, as expected, via git checkout student.
Syzygy
  • 1,754
  • 1
  • 9
  • 12

1 Answers1

1

I don’t have experience with GitStack but apparently it does store its repositories within C:\GitStack\repositories. So you should be fine with just reinstalling it and then recovering your repository data from your old C:\GitStack\repositories.

In case there are some repository-unrelated settings, those might be stored within C:\GitStack, so you could try to recover those from there too. I would assume that as long as you install the same version as your previous installation, you can just recover all files from C:\GitStack.

And of course, as Git is a distributed version control system, this means that every local repository is a full clone of the remote repository. So if recovering the repositories does not work, you can also simply create new repositories in GitStack and then push the old history from your local repositories to it. That way you will be able to recover all the history completely.

poke
  • 369,085
  • 72
  • 557
  • 602
  • Thanks much for your response! Sorry for the question, but if I went the route in your last paragraph, how would I push the history into a new Git repository? – Syzygy Mar 12 '18 at 06:39
  • 1
    @Syzygy From your local repository, you set up a new remote using [`git remote`](https://git-scm.com/docs/git-remote) and then you just push to it. See also [“Working with Remotes”](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes). – poke Mar 12 '18 at 08:02
  • I had two branches for my project. Given that you your repository can only be on one branch at a time, obviously only the master branch was checked out on my hard drive (though I had previously checked out the "student" branch also). Will the remote option work in this case? – Syzygy Mar 13 '18 at 03:35
  • 1
    When you clone a repository, you get a full copy of the repository, including the full history and all branches. So the other branches should be still there too. You can check that with `git branch`. – poke Mar 13 '18 at 08:52
  • I finally got around to doing this, and in so doing, accepting your answer. Your advice was solid, thank you! I've edited the solution procedure underneath the body of my original question. – Syzygy Apr 05 '18 at 02:08