Search code examples
visual-studiogitprojectssolution

Moving a Git repository from a Visual Studio solution


I am only a very beginner user of git and have a C# Visual Studio solution (sln) with 5 projects in it. I already understand that I need to have also 5 different git 'projects' for that.

Currently these Git projects are stored in a directory in my sln directory but I rather have it on a separate disk, including history information etc. How should I do this (in a safe way)?

Edit/update: Is this the same as using the clone command from inside the git extension in visual studio: I get the output:

c:\Program Files (x86)\Git\bin\git.exe clone -v --bare --progress "G:/Data/Eigen/Informatica/KorgKronosTools/KorgKronosTools/" "d:/git/KorgKronosTools" Cloning into bare repository d:/git/KorgKronosTools... done. Done


Solution

  • What you want is a remote repository:

    cd c:\backup\
    mkdir project-X 
    cd project-X
    git --bare init
    

    then go to your existing repository and inside it:

    git remote add origin file://c:/backup/project-X
    git push origin master
    

    now every time you think its a good time to backup, run git push origin master and the changes you made in the existing directory will be pushed to the "remote" directory.