How to add a remote folder share as a remote git repository in vs code?

In some cases, you might just wanna push your code to a network folder and use that as your remote. This will also work without vscode as long as you can get to the command line and you have the necessary folder permissions. Here is how ๐Ÿ‘

First you will need to initialise your remote repository. You can open git bash or a vscode terminal and use the following:

git init --bare

The bare tag is important! I means nothing is in there, so its able to be pushed to!

Next we need to go to our local working folder, and if we havent initialised a git repo there we can use:

git init

Now to add our remote!

git remote add origin "\\\your\share\folder\path\your remote git folder"

Lets decode this

  1. Notice the extra \ at the start? that is needed as the “\ seems to be combined as ” your results may vary and you may only need two
  2. All the slashes are BACK slashes ๐Ÿ˜‰
  3. Put a ” on the end to close the quotes
  4. Notice the “origin”? That is like the friendly name for the remote. Origin seems to be the default in most cases

Next, you will probably want to push, so you can make some changes in your folder, then

  1. git add .
  2. git commit -m “your commit message”
  3. git push origin

And there you should have it! Hope this helped!


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *