0

Say I have my existing VS2015 code in C:\Proj1, and I have created a repository in C:\Repo\Proj1.

Now I want to connect my project at C:\Proj1 to the Repository at C:\Repo\Proj1.

The problem is when I click on the Publish button in the lower right end of VS2015 window, of VS2015 project (loaded from C:\Proj1), it creates the GIT Repository locally inside my project directory (the hidden .git directory, attributes and ignore files). Instead of connecting to the local .git repository, I would like to connect to the repository at C:\Repo\Proj1, everytime I open/use my VS2015 project in C:\Proj1

I am using VS2015 (SP3) on Win10.

How to do it? Thanks in advance...

XMarshall
  • 953
  • 3
  • 11
  • 23

3 Answers3

0

I'm not exactly sure what you mean by

Now I want to connect my project

I believe you're going to want to move/copy your source code into the repo directory (with the .git folder).

And then work out of the repo directory.

You can start a new repo with git clone or git init and then you will want to work out of that directory so the .git folder can track everything.

JBoothUA
  • 3,040
  • 3
  • 17
  • 46
  • 1
    Thanks to everybody for their Answers. My idea was to keep the Repository in a separate directory, other than my actual project directory. Because, what if I delete my actual project directory my mistake, I can then have my files back from the repository again. Off course since .git directory is hidden, it will not be deleted or I will be asked if I want to delete it. Basically, I was trying to implement the same concept of URL based remote Repository, but in my case, it will be in my same local machine, but in a different location. Probably I am not thinking in the right direction... – XMarshall Nov 09 '18 at 14:44
0

You can make your project at C:\Proj1 a submodule of C:\Repo\Proj1

Just go to C:\Repo\Proj1 and execute in bash:

git submodule add C:/Proj1

Then go to C:\Proj1:

git submodule init
git submodule update

Find more here: https://stackoverflow.com/a/36554930

mibrl12
  • 454
  • 5
  • 21
0

It sounds to me as if you have created the repository in the wrong place.. perhaps you could symlink the folders inside.

You can do this using an elevated command prompt;

mklink /d "C:\Repo\Proj1" "C:\Proj1"

/d - create a directory link (https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mklink)

Quote's aren't required if you don't have spaces in the directory names - but imo are recommended for good practice.

essdeeeff
  • 31
  • 7