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?
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?
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/
Yes, it's possible with Git. I use this method frequently to play
around with git pull/git push commands without the need for using
network.
Example (you didn't specify what system you use so I assumed Unix):
Create a remote git repository in /tmp/orig-repository:
$ mkdir /tmp/orig-repository
$ cd /tmp/orig-repository
$ git init --bare
Initialized empty Git repository in /tmp/orig-repository/
Clone the newly created repository in /tmp/clone-repository:
$ mkdir /tmp/clone-repository
$ cd /tmp/clone-repository
$ git clone /tmp/orig-repository
Cloning into 'orig-repository'...
warning: You appear to have cloned an empty repository.
done.
$ cd orig-repository
Make a test file and push changes:
$ touch file
$ git add file
$ git commit -m 'add file'
[master (root-commit) 5f365e5] add file
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file
$ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 209 bytes | 209.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To /tmp/orig-repository
* [new branch] master -> master
Notice that origin/master exists:
$ git branch -r
origin/master
You can clone /tmp/orig-repository to another repository on your
filesystem, push, then do git fetch in /tmp/clone-repository - just as if
you used Github or any remote Git server.
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