Tag Archives: fatal: remote origin already exists.

Git Error: fatal: remote origin already exists.

Today, when using git to add a remote GitHub warehouse, you will be prompted with an error: fatal: remote origin already exists

Finally, the solutions are as follows:
1. Delete the remote git warehouse first

$ git remote rm origin

2. Add remote git warehouse

$ git remote add origin [email protected] :FBing/java-code-generator

If an error is reported when git remote RM origin is executed, we can manually modify the contents of the gitconfig file

$ vi .git/config

How to Solve Code cloud error: fatal: remote origin already exists

 1 Today, when submitting Git, I encountered a few problems, so I'll record them for future reference O(∩_∩)O
 2 
 3 The first problem
 4 
 5 git remote add origin**************
 6 fatal: remote origin already exists.
 7 
 8 After checking on the Internet, there are many white people who have encountered this problem, and the following is the solution extracted from the Internet.
 9 The solution is as follows.
10 1, first type git remote rm origin
11 2. Then type git remote add origin **************
12 
13 This will not report an error!
14 
15 Second problem
16 
17 git remote add origin******
18 The authenticity of host 'github.com ' can't be established
19 
20 This is because your git address is ssh, switch to https, or maybe your repository address is wrong, check it first with the command
21 git remote -v
22 
23 If it's not the same as your github address, go to your github and copy the repository address
24 Then in the terminal, type
25 git remote-set-url origin https://github.com/yourname/learngit.git (this is the address of your copied repository)
26 
27 And finally, just push!
28 git push origin master

GitHub common operations and common errors! Error prompt: fatal: remote origin already exists

If you enter $git remote add origin [email protected] : djqiang (GitHub account name)/gitdemo (project name). Git

Prompt error message: fatal: remote origin already exists

The solution is as follows:

1. Enter $git remote RM origin first

2. Then enter $git remote add origin [email protected] : djqiang/gitdemo.git will not report error

3. Error: could not remove config section ‘remote. Origin’. We need to modify the content of gitconfig file

4. Find the installation path of your GitHub, and mine is C:: (users) ﹣ ASUS ﹣ appdata ﹣ local ﹣ GitHub ﹣ portablegit_ ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc

5. Find a file named gitconfig, open it, and delete the line [remote “origin”]

If you enter $SSH – t [email protected]
There is an error prompt: permission denied (public key). Because the newly generated key cannot be added to SSH, the connection to GitHub cannot be made

The solution is as follows:

1. Enter $SSH agent first, and then $SSH add ~ /. SSH/ID_ Key, that’s it

2. If not, enter SSH add ~ /. SSH/ID_ Can not open a connection to your authentication agent. The solution is to use git GUI’s SSH tool to generate the key. In this way, the key will be directly saved in SSH when it is generated. There is no need to add the SSH add command. Other user, token and other configurations will be done with the command line

3. It’s better to check the ID in your copy_ If there are any extra spaces or empty lines in the content of the rsa.pub file, some editors will help you add these

If you enter $git push origin master

Error message: error:failed to push som refs to …….

The solution is as follows:

1. Enter $git pull origin master// first pull down the files on the remote server GitHub

2. Enter $git push origin master

3. If an error is reported, fatal: couldn’t find remote ref master or fatal: ‘origin’ does not appear to be a git repository and fatal: could not read from remote repository

4. You need to re-enter $git remote add origin [email protected] :djqiang/gitdemo.git

The process of creating a project locally using Git

$makdir ~/Hello World// create a project Hello World
$Cd ~/Hello World// open the project
$git init// initialize
$touch readme
$git add readme// update the readme file
$git commit – M ‘first commit’// submit the update, And annotate the information “first commit”
$git remote add origin [email protected] : defnngj/hello-world.git// connect to remote GitHub project
$git push – U origin master// update local project to GitHub project

Gitconfig configuration file

Git has a tool called git config, which allows you to get and set configuration variables; These variables control all aspects of GIT’s appearance and operation. These variables can be stored in three different locations:
1./etc/gitconfig file: contains values applicable to all users and all libraries of the system. If you pass the parameter option ‘– system’ to git config, it will explicitly read and write the file
2. ~ /. Gitconfig file: specific to your users. You can make git read or write this particular file by passing the — global option in windows, GIT looks up the. Gitconfig file in the $home directory (for most people, it’s under C:// documents and settings \ $user). It also looks for/etc/gitconfig, although it is relative to the msys root. This could be anywhere you decide to install git when you run setup on windows

Configuration information:

2.1 When you install git, the first thing to do is to set your user name and e-mail address. This is very important because this information is used every git submission. It’s embedded in your submission forever:

  $ git config –global user.name “John Doe”

  $ git config –global user.email [email protected]

2.2 your editor

Now that your logo has been set, you can configure your default text editor, which git will use when you need to enter some messages. By default, GIT uses your system’s default editor, which is usually VI or vim. If you want to use a different text editor, such as Emacs, you can do the following:

  $ git config –global core.editor emacs

2.3 checking your settings

If you want to check your settings, you can use git config — list to list all the settings git can find there

  $ git config –list

You can also check the current value of a specific keyword that git thinks. Use the following command git config {key}:

  $ git config user.name

2.4 getting help

If you need help when using git, there are three ways to get the man page help information of any git command:

  $ git help < verb>

  $ git < verb> — help

  $ man git-< verb>

For example, you can run the following command to get man page help for the config command:

$git help config
— –
Author: dengjianqiang2011
source: CSDN
original text: https://blog.csdn.net/dengjianqiang2011/article/details/9260435?utm_ Source = copy
copyright notice: This article is the original article of the blogger, please attach the blog link if you want to reprint it

Git Error: fatal: remote origin already exists [How to Solve]

When you enter $git remote add [email protected] : djqiang (GitHub account name)/gitdemo (project name). Git

The following error occurred:

The solution is as follows:

1. Enter $git remote RM origin first

2. Then enter $git remote add origin [email protected] : djqiang/gitdemo.git will not report error

3. Error: could not remove config section ‘remote. Origin’. We need to modify the content of gitconfig file

4. Find the installation path of your GitHub, and mine is C:: (users) ﹣ ASUS ﹣ appdata ﹣ local ﹣ GitHub ﹣ portablegit_ ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc

5. Find a file named gitconfig, open it, and delete the line [remote “origin”]