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