# git remote: connect a repository to another one

Published: 2026-11-30

Rights: original
Source: https://kairos-2z6s.onrender.com/res/git-remote-full-en
A remote is a name for a URL, which may be a path on the same machine or a remote address; fetch and push URLs can differ.

Each command below is the exact command that was run and each output block is copied from the recorded log. Test ids, log hashes and exit statuses are in the evidence table.

(Test: 3 tests were run, TE-16-A, TE-16-B and TE-16-C. The expected non-zero exit is TE-16-C (exit status 128). Every row has a recorded log in the evidence archive. The evidence table lists the exit status and log hash of every row, and no Exit status line on this page is for the A row.)

### TE-16-A: a remote can be a path on the same machine, not only a server

Setup for this run, inside a throwaway directory (`mktemp -d`):

```bash
git init -q .
git symbolic-ref HEAD refs/heads/main
git config user.email test@example.invalid
git config user.name tester
git config commit.gpgsign false
printf 'one\n' > f.txt; git add f.txt; git commit -qm one
git init -q --bare ../bare.git
```

Paths written as `../name` sit one level above the repository folder, inside the same throwaway tree, so they do not appear in `git status`.

Command:

```bash
git remote add origin ../bare.git; git push -q origin HEAD:main; echo push=$?
```

Recorded output:

```
push=0
```

Check command and its recorded output:

```bash
git remote -v | head -1; git ls-remote --heads origin | wc -l
```

```
origin	../bare.git (fetch)
1
```

### TE-16-B: git remote -v lists the fetch and push address of a remote added with a relative path

Setup for this run, inside a throwaway directory (`mktemp -d`):

```bash
git init -q .
git symbolic-ref HEAD refs/heads/main
git config user.email test@example.invalid
git config user.name tester
git config commit.gpgsign false
printf 'one\n' > f.txt; git add f.txt; git commit -qm one
git init -q --bare ../bare.git
git remote add origin ../bare.git
```

Command:

```bash
git remote -v
```

Recorded output:

```
origin	../bare.git (fetch)
origin	../bare.git (push)
```

Exit status: 0. This status and the output match what was written before the run.

### TE-16-C: expected non-zero exit: pushing to a remote name that has not been added stops with a fatal error

Setup for this run, inside a throwaway directory (`mktemp -d`):

```bash
git init -q .
git symbolic-ref HEAD refs/heads/main
git config user.email test@example.invalid
git config user.name tester
git config commit.gpgsign false
printf 'one\n' > f.txt; git add f.txt; git commit -qm one
```

Command:

```bash
git push -q nosuch HEAD:main
```

Recorded output: none, standard output was empty.

Standard error from the same run:

```
fatal: 'nosuch' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
```

Exit status: 128. This status and the output match what was written before the run.

## Reading the recorded output

The line push=0 is the exit status of git push to ../bare.git, a bare repository in a folder on the same machine. git remote -v printed origin with the path ../bare.git and the word fetch in parentheses as its first line, and the run keeps only that first line. For git ls-remote --heads origin the run printed the count of branch lines, which is 1, so the bare repository has one branch after the push.

TE-16-B: git remote -v printed origin ../bare.git (fetch) and origin ../bare.git (push), the path given to git remote add. TE-16-C: git push to the name nosuch exited with status 128. The first line of standard error is fatal: 'nosuch' does not appear to be a git repository.

## Limits

A remote may be a path on the same machine or a URL; it is not necessarily a server on the internet.

## Source

- https://git-scm.com/docs/git-remote

## Evidence

- `TE-16-A`: a remote can be a path on the same machine, not only a server

- logs: one recorded log for each row above
- Recorded on: Linux x86_64, kernel 7.3.4; bash 5.1.16; git 2.34.1; python 3.10.12; findutils 4.8.0; grep 3.7; sed 4.8; gawk 5.1.0; tar 1.34; curl 7.81.0. Locale C.UTF-8, TZ=UTC.

## Evidence table

| Test | What it checks | Exit | Verdict | Log sha256 (first 12) |
|---|---|---|---|---|
| `TE-16-A` | a remote can be a path on the same machine, not only a server | 0 | PASS | `4512703726ee` |
| `TE-16-B` | git remote -v lists the fetch and push address of a remote added with a relative path | 0 | PASS | `edf08938ac8f` |
| `TE-16-C` | expected non-zero exit: pushing to a remote name that has not been added stops with a fatal error | 128 | PASS | `b9b09d92a2ae` |

Every row has a recorded log holding the setup commands, the command, stdout, stderr, exit status and the final directory state. The first 12 characters of the log's sha256 are in the table.

## Related guides
- [Git Stash: set aside uncommitted work](https://kairos-2z6s.onrender.com/res/git-stash-full-en)
- [git tag: name a commit, lightweight and annotated](https://kairos-2z6s.onrender.com/res/git-tag-full-en)
- [git reset: soft, mixed and hard on the same repository](https://kairos-2z6s.onrender.com/res/git-reset-modes-full-en)
- [Git Reflog: the history of where HEAD pointed](https://kairos-2z6s.onrender.com/res/git-reflog-full-en)
- [Git Mv: rename a tracked file](https://kairos-2z6s.onrender.com/res/git-mv-full-en)
