GitHub common operations and errors! Error message: Fatal: remote origin already exist

Source: Internet
Author: User

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

Error message: Fatal: remote origin already exists.

The solution is as follows:

1. Enter $ git remote RM origin first

2. Enter $ git remote add origin [email protected]: djqiang/gitdemo. Git. No error will be reported!

3. If you enter $ git remote RM origin or report an error, error: cocould not remove config section 'remote. origin'. We need to modify the content of the gitconfig file.

4. Find your GitHub installation path. my options are c: \ Users \ Asus \ appdata \ Local \ GitHub \ portablegit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8 \ etc.

5. Find a file named gitconfig and open it to delete the [remote "Origin"] line!

 

 

If you enter $ ssh-T [email protected]
Error message: Permission denied (publickey). Because the new key cannot be added to SSH, the connection to GitHub will fail.

The solution is as follows:

1. Enter $ ssh-agent first, and then $ ssh-add ~ /. Ssh/id_key.

2. If the problem persists, enter ssh-add ~ /. An error occurs after the ssh/id_key command: cocould not open a connection to your authentication agent. the solution is to generate the key using the SSH tool of git GUI, so that the key will be saved directly in SSH when the key is generated. You do not need to add the ssh-add command. Other users, the token and other configurations are all done using the command line.

3. Check that there are no extra spaces or blank lines when you copy the content of the id_rsa.pub file. Some editors will help you add these lines.

 

 

If you enter $ git push origin master

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

The solution is as follows:

1. First enter $ git pull origin master // first pull the file above the remote server GitHub

2. Enter $ git push origin master.

3. If the following error occurs: Fatal: Couldn't find remote ref master or fatal: 'origin' does not appear to be a git repository and fatal: cocould not read from remote repository.

4. Enter $ git remote add [email protected]: djqiang/gitdemo. Git again.

 

 

Use git to create a project locally

$ Makdir ~ /Hello-world // create a project hello-world
$ Cd ~ /Hello-world // open this project
$ Git init // Initialization
$ Touch readme
$ Git add readme // update the README file
$ Git commit-m'first commit '// submit the update and comment out the "first commit"
$ Git remote add origin [email protected]: defnngj/hello-world.git // connect to a remote GitHub Project
$ Git push-u origin master // update the local project to the GitHub Project

 

Gitconfig configuration file

Git has a tool called git config that allows you to get and set configuration variables. These variables can control the appearance and operations of git. These variables can be stored in three different locations:
1./etc/gitconfig file: contains values applicable to all users and 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 user. You can enable git to read or write this specific file by passing the -- global option.
3. the config file (that is,. Git/config) in the GIT Directory: No matter what library you are currently using, it points to this single library. Each level overrides the value of the previous level. Therefore, the value in. Git/config overwrites the same value in/etc/gitconfig.
In Windows, git searches for the. gitconfig file in the $ home directory (for most people, under c: \ Documents ents and Settings \ $ user ). It will also find/etc/gitconfig, although it is relative to the msys root directory. This may be wherever you decide to install git when running the installer in windows.

 

Configuration information:

2.1 The first thing you need to do after installing git is to set your user name and e-mail address. This is very important because this information is used every time a git commit is made. It is always embedded in your submission:

$ Git config -- global user. Name "John Doe"

$ Git config -- global user. Email [email protected]

 

2.2. Your editor (your editor)

Now, your ID has been set. You can configure your default text editor. Git will use this text editor when you need to enter some messages. By default, git uses the default editor of your system, which may be 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 check your settings (checking your settings)

If you want to check your settings, you can use the GIT config -- LIST command to list all the settings that git can find here:

$ Git config -- list

You can also view the current value of a specific keyword that git deems, and use the following command git config {key }:

$ Git config user. Name

 

2.4 getting help)

If you need help when using git, you can obtain the help information on the manual page (manpage) of any git command in three ways:

$ Git help <verb>

$ Git <verb> -- Help

$ Man Git-<verb>

For example, you can run the following command to obtain help on the config command manual page:

$ Git help config

GitHub common operations and errors! Error message: Fatal: remote origin already exist

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.