banner



how to remove remote origin git

In this article, we'll continue the Linux how-to series and guide you on how to remove a Git remote repository. We'll cover the difference between local and remote repositories and two possible workflows for Git remote repository. Take a look at our infographics to learn everything in less than one minute!

What is Git

Git is a free and open-source distributed version control system. Linus Torvalds designed it in 2005, and now Git is one of the most popular code version control systems in the world. Git helps you to maintain the history of changes that you made during your software development process.

Local Git Repository

Git is a decentralized distributed version control system. That means that you can store your software code changes on your local PC or remote server. Software changes that you keep locally forming the local repository.

Local repository developer workflow

To create (or initiate) a local repository, you're using the following command:

          $ git init        

To add and commit your changes to your local Git repository, use:

          $ git add  $ git commit        

Remote Git Repository

To simplify a software development process for distributed teams, people started to use a dedicated server as a central place for code exchange. Git repository at such server is called a remote repository. Nowadays, we have several Git hosting services, such as Bitbucket, Github, or GitLab.

Here's the most straightforward workflow with one remote repository:

Local and single remote repository for development workflow

We can add information about the remote Git repository to our local repository using the following command:

          $ git remote add origin git-remote-url        

Where:

  • origin – is the logical name or remote repository; theorigin is the default name for the remote repositor.
  • git-remote-url – is the URL of the remote repository; usually, you're getting it at your repository page at GitHub.

Cloning a Git repository from a remote server creates theorigin automatically at your local repository.

For the case of a distributed team using the same remote repository, here's another diagram:

Developers collaboration (workflow) using single remote repository

In the open-source world, team workflow is a bit different. A distributed team is not pushing code changes directly to a single repository, but they send pull-requests. Using pull-requests instead of committing directly to a single repository is a more efficient way to control changes coming to it.

To not overcomplicate the diagram, we'll show only one developer workflow, working with his remoteorigin and sending pull requests to theupstream repository.

Two remote Git repositories

Removing a Git Remote URL

Before deleting any records of remote Git repositories, it makes sense to list them first:

          $ git remote -v        
git remote - command

To remove one of the listed remote repositories, use the following command:

          $ git remote rm origin        

This command will remove anorigin from the remote list:

git remote rm origin - command

Thegit remote rm command removes the specific remote from the.git/config file located in your project folder.

Another way to remove the remote repository is to edit the.git/config file, but this method is not the most widely-used.

If you're trying to remove a remote repository that does not exist, Git throws an error.

          $ git remote rm origin        

The output isfatal: No such remote: 'origin':

git remote rm origin -  failed command

Usually, the above error can also be caused by mistyping the remote repository name.

Thegit remote rm command has an aliasgit remote remove, which works in the same way:

          $ git remote remove git-repository-logical-name        

Summary

In this article, you've learned how to remove information about the remote Git repository from our local repository.

If you have any questions, please, feel free to reach out in the comments section below.

  • Easy way to connect to multiple AWS CodeCommit repositories
  • Terraform – Deploy Python Lambda (container image)
  • How to Set Up Remote Desktop on Ubuntu (Xrdp)
  • Top 10 SSH Features You MUST Know To Be More Productive
  • How To Remove Files And Directories In Linux

How useful was this post?

Click on a star to rate it!

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

how to remove remote origin git

Source: https://hands-on.cloud/how-to-remove-git-remote-repository/

Posted by: beaverondowde.blogspot.com

0 Response to "how to remove remote origin git"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel