Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible for the Git remote to be a location on the computer itself rather than on a network location?

Tags:

git

I have so far seen that the git remote is on network. Is it possible for it to be a location on the computer itself like another drive or another directory? If so, how?

like image 841
gyuunyuu Avatar asked Nov 25 '25 09:11

gyuunyuu


2 Answers

https://git-scm.com/docs/git-pull#_git_urls

For local repositories, also supported by Git natively, the following syntaxes may be used:

/path/to/repo.git/
file:///path/to/repo.git/
like image 117
phd Avatar answered Nov 28 '25 00:11

phd


Yes. For local repositories, a remote can be a relative path or an absolute path to another local folder. Besides, it can be in the syntax file:///path/to/folder. And here are more facts about the remote.

A remote can be a git bundle, as a read-only one.

git init /path/to/foo
cd /path/to/foo
touch a.txt
git add .
git commit -mfoo
git bundle create /path/to/foo.bundle master

git init /path/to/bar
cd /path/to/bar
git remote add origin /path/to/foo.bundle
# it's possible to fetch data from the bundle
git fetch origin master
git checkout master
# it's not possible to push data to the bundle
# git push fails

A remote can be the repository itself.

git init /path/to/foo
cd /path/to/foo
touch a.txt
git add .
git commit -mfoo

# add a remote which is the repository itself
git remote add origin .
# or
git remote add origin /path/to/foo

# push "master" to create a new branch "new_master"
git push origin master:new_master

A remote can be any repository which is accessible from the current repository, even if the two repositories are completely different.

git clone https://github.com/arobson/rabbot
cd rabbot
git remote add new https://github.com/fooplugins/FooTable
git fetch new
like image 34
ElpieKay Avatar answered Nov 28 '25 00:11

ElpieKay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!