

So, if anything is still confusing, I’d encourage you to re-read this article and dig into the documentation linked above, as well as try out the examples and everything else you find for yourself.
GIT ADD REMOTE BRANCG CODE
Nota bene: It’s easy to just copy and paste random bits of code that you find on Google to quickly fix the error, but generally speaking it’s much more useful to understand the underlying concepts so that you don’t have to keep Googling the same commands over and over again. For further reading, you can find formal documentation on the `git remote` command here. I am not sure if you are trying to create a remote branch from a local branch or vice versa, so I’ve outlined both scenarios as well as provided information on merging the remote and local branches. ConclusionĪs I mentioned at the beginning of this article, we broke down the concept of remote repositories in Git and went over a few of the most common commands that you’ll need to understand in order to use them properly.

And again - the solution is to use `git remote set-url` instead of `git remote add`. Since “origin” is such a common convention, there’s a good chance that any repository you clone already has a remote configured with this name, because remotes are included when a repository is cloned.Ĭloning a repository and trying to add your own remote server to “origin” without realizing that that name is already in use is a very common way this error is caused.
If you want to see it all together: git init git remote add originIf your remote repository is empty, this will automatically create a master branch. It is a shared repository that all team members use to exchange their changes. Run the following commands to check the branch list of the local repository after running the fetch command and create a new local branch to track the remote branch. In the below screenshot, you can see that the remote repository origin that the tutorial is using is shown as expected. First, we add all of the files with add -A, then commit them with a message. In Git, the term remote is concerned with the remote repository. The following output shows that the new branch named master is added to the remote repository. To show the remote branches as well, append the all switch, as shown below. At first glance it’s not obvious whether “origin” is part of the `git remote` command or just a parameter, a misconception that is further supported by the wording of the Git error: it’s not obvious that “origin” is a parameter, and not a part of the failing command.Īnd yes, this means that the error thrown at the top of the article could just as easily read “fatal: remote cheese already exists.” Remote “origin” might've been configured if you cloned the repo Display all available branches, both local and remote, in your repository with the branch command. It’s frustrating, because this convention is actually the primary source of remote naming errors. It’s worth noting that using “origin” for the name of your default remote repository is simply a convention - you could name your default remote “cheese” for all the difference it would make. “origin” is a convention, not a part of the `git remote` command
