git
repository
remove origin
version control
GitHub

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.

bash
git remote -v

Typical output looks like this:

text
origin  [email protected]:example/project.git (fetch)
origin  [email protected]:example/project.git (push)

If you have more than one remote, deleting origin will only remove that specific entry.

Remove origin

The command is short:

bash
git remote remove origin

This older alias works too:

bash
git remote rm origin

After running it, verify the result:

bash
git remote -v

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:

bash
git fetch origin

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.

bash
git remote remove origin
git remote add origin [email protected]:new-owner/project.git

Then verify:

bash
git remote -v

If you want the current branch to push to the new remote, you may also set upstream tracking:

bash
git push -u origin main

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.

bash
git remote rename origin upstream

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

  • 'origin is just the default name for a Git remote.'
  • Remove it with git remote remove origin or git remote rm origin.
  • Deleting origin does not affect commits, branches, or files.
  • Add a new remote afterward if the repository has moved.
  • Use git remote rename instead if you only want a different remote name.

Course illustration
Course illustration

All Rights Reserved.