How to remove origin from git repository
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In Git, origin is just the default name for a remote, not a special built-in thing that your repository must always have. Removing it is simple, and it only changes the local remote configuration, not your commits or working tree.
What origin actually is
When you clone a repository, Git usually creates a remote named origin that points to the source URL. That remote is stored in local repository config and is used by commands such as git fetch origin and git push origin main.
The important point is that origin is only a label. You can remove it, rename it, or replace it with a different remote at any time.
Check the current remotes first
Before deleting anything, inspect the repository's remotes so you know exactly what is configured.
Typical output looks like this:
If you have more than one remote, deleting origin will only remove that specific entry.
Remove origin
The command is short:
This older alias works too:
After running it, verify the result:
If origin was the only remote, the command will produce no remote lines.
What changes and what does not
Removing origin affects only remote configuration. It does not:
- delete local branches
- delete commits
- modify tracked files
- remove branch history
It only means your repository no longer knows where origin points. Commands that explicitly reference origin will fail until you add or rename a remote again.
For example, after removal, this will fail:
That failure is expected because the name no longer exists.
Replacing origin with a new remote
A common reason to remove origin is that the hosting location changed. In that case, you often remove the old remote and immediately add a new one.
Then verify:
If you want the current branch to push to the new remote, you may also set upstream tracking:
Replace main with the actual branch name you are using.
When renaming is better than removing
If the only goal is to change the label from origin to another name, renaming is cleaner than delete-then-add.
That preserves the URL and just changes the remote name.
This is common in fork workflows where upstream points to the original project and origin points to your fork.
Common Pitfalls
The biggest mistake is thinking origin is part of the repository history. It is not. It is only local configuration.
Another issue is removing the remote and then being surprised when git pull or git push stops working. Those commands rely on a configured remote and branch tracking setup.
It is also easy to confuse removing a remote with deleting a remote repository. git remote remove origin does not delete anything on GitHub, GitLab, or any server. It only removes the local reference.
Finally, if a script or CI job assumes the remote name is origin, renaming or removing it may break automation. Check your tooling before changing shared workflows.
Summary
- '
originis just the default name for a Git remote.' - Remove it with
git remote remove originorgit remote rm origin. - Deleting
origindoes not affect commits, branches, or files. - Add a new remote afterward if the repository has moved.
- Use
git remote renameinstead if you only want a different remote name.

