Go to your local repository and remove the existing origin remote.Īdd the new online repository as the correct origin remote. To go about that, you could follow the steps below:Ĭreate a new repository online using GitHub or GitLab. Let's say, for the sake of the example, that you used to use GitLab for storing your repositories online and then decided to switch over to GitHub (or vice versa). The first scenario we'll cover is the one in which there's already a remote called origin, but it's the wrong remote for some reason. Keep in mind that the solution you'll use will depend on your specific situation because there are a few different scenarios that can cause this problem to happen. Having explained why the error message happens, we'll now cover some of the several potential solutions you can use to solve the problem. Solving the "Remote Origin Already Exists" Error in Four Different Ways Similarly to the way that the default branch in Git is called controller-though that could change in the near future-the default remote is called origin, but you could name it anything you like as long as it's a legal name in Git. In this case, the error message would say: That will return not only the names of each remote but also its URLs:īy the way, the message will not always contain the actual word "origin." Let's say you're trying to add a remote called cloudbees but there's already a remote with that name. If you want to get more detail, you can add the verbose parameter with the remote command, like this: That will make your Git list all existing remotes for the current repository. If you want to be really sure the remote called origin actually exists, you can easily check that by running the following command: So if you try to add a remote with the same name as an already existing remote, boom! Fatal error. However, you can't have two remotes with the same name. Remotes have names to identify them, and you can have as many remotes per repository as you need or want. Keep in mind that, despite the name, remotes aren't necessarily located on remote machines: despite sounding like an oxymoron, local remotes are totally possible. Those are usually on machines other than your own, and you access them via SSH or HTTP. Remotes represent repositories that you might have read and/or write access to. In Git, you can have what we call remote repositories, or simply remotes. Unlike centralized VCSs, Git doesn't have a central server. Understanding this message is actually easy. Then, you see a line similar to the following one:Īfter trying to execute the command above, you get the infamous error message: Picture this: You're following a Git tutorial you've found online. "Remote Origin Already Exists" Error: Why Does It Happen? In this post, we'll give more detail into why that error message happens in the first place and then show you a few different ways in which you can address it. That's not that different from your operating system preventing you from creating a file with the same name as an already existing file. It clearly states what the problem is: you're trying to add a remote called origin, but you already have one with that name. As far as Git error messages go, this one is pretty straightforward, unlike other weirder messages. Today, we'll add another installment to the series by covering an issue you might bump into when following Git tutorials over the web: the "remote origin already exists" error. To help you along your learning journey, we've been covering common Git pitfalls and explaining how to get out of them. The tool originally created by Linus Torvalds-yes, the creator of the Linux kernel-has become the de facto standard when it comes to source control solutions. Do you write code for a living? Then learn Git, and learn it well.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |