git · Git
The message
fatal: remote origin already exists.
What it means
The name origin is already in use in this repository, so it cannot be created a second time. A cloned repository has origin from the start, and the message appears when you follow a fresh-repository guide inside one and run git remote add origin. Check where origin points with git remote -v first; if what you wanted was a different URL, git remote set-url origin changes only where it points. This setting is one line in .git/config, reversible at any time and with no effect on your commits.
The fix
git remote set-url origin git@github.com:user/repo.git- Printed by
- git
- Git
- 29
Almost every git error is a refusal that means "doing that from this state would lose something"; fatal: means git stopped without changing anything, and the hint: lines under the first line usually carry the actual remedy.
Reading an error message
- Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
- If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
- Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
- The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
- Before pasting a fix, check what it throws away. Some of these cannot be undone.
Common questions
Q. What does “fatal: remote origin already exists.” mean?
The name origin is already in use in this repository, so it cannot be created a second time. A cloned repository has origin from the start, and the message appears when you follow a fresh-repository guide inside one and run git remote add origin. Check where origin points with git remote -v first; if what you wanted was a different URL, git remote set-url origin changes only where it points. This setting is one line in .git/config, reversible at any time and with no effect on your commits.
Q. How do I fix it?
git remote set-url origin git@github.com:user/repo.git — before running it, check the explanation above for what this command discards.
Q. Which tool prints this?
git. It sits under Git, and the message runs to 5 words.