3

I have a Visual Studio 2013 solution, and I decided to use Git for source control. When I ran the tool within VS2013 to create the repository, of course it created it within the same folder as the solution. Fine, except I want the repository to be held in a network location where it will be subject to regular backup.

I've gone over a number of answers to similar questions here on SO, but none of them seem to apply to VS2013, and some of the instructions seem to involve "running" some sort of Git tool, without specifying what it is, or how one would start it. What I want to do is move the repository from my C: drive to the network based I: drive. Once it is moved, I want Git to update the repository in its new location. The existing repository seems to be consist of two files in the solution folder: .gitattributes and .gitignore. There's a Git folder (hidden) named .git.

I am guessing I can move the .git folder to the I: drive location, and then I need to perform some Git command to link the moved repository with the VS solution. Is this correct, and what is this Git command or commands and how do I execute it or them?

When answering, please keep in mind that for all practical purposes I know Zip about Git.

Cyberherbalist
  • 11,515
  • 15
  • 77
  • 119
  • Your workflow does not seem usual. 1. You want to always have `.git` directory in the same directory as your code 2. You create a central repository and periodically push there (backup) – zerkms Oct 20 '14 at 23:45
  • @zerkms - OK, I had hoped there were an automatic push (like when code changes occurred that caused "checkouts" and were later, for example, "checked in"). Can you provide an answer to this effect? E.g. how do I create such a central repository and connect it to the local? I have previously worked with Visual Source Safe, and typically the sourcesafe itself was kept in a network location, with code checkouts and checkins performed by Visual Studio. I had assumed it would be similar in Git. – Cyberherbalist Oct 20 '14 at 23:56
  • 2
    The downvoter needs to give a reason for the downvote. So I can improve the question, dammit. – Cyberherbalist Oct 21 '14 at 00:07
  • With git it's supposed that you always have a complete local copy of the repository that is optionally might be synchronized with some other one (we may call it "central" for simplicity). How to install it - depends on what operating system you're running on the destination server (it would be **MUCH** better if it was linux). PS: +1'd just because this question doesn't deserve to be downvoted indeed – zerkms Oct 21 '14 at 00:12
  • Thankyou @zerkms; sorry it's definitely Windoze, lol. – Cyberherbalist Oct 21 '14 at 00:19

1 Answers1

0

It is best to keep your local repo on your local disk (much faster access).

But should want a second repo acting as a backup for the first repo, all you need to do (using git command line) is:

cd I:\
git init --bare yourRepo.git
cd C:\path\to\your\local\repo
git remote add backup I:\yourRepo.git
git push backup master

Then you can setup a Windows task to push at regular interval your local repo to the bare repo on I:\yourRepo.git.
See here to understand why you want to push to a bare repo.

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283