Common git operations and common errors

Source: Internet
Author: User
Tags commit join ssh using git
Original link: http://blog.csdn.net/dengjianqiang2011/article/details/9260435

If you enter Git remote add Origin Git@github.com:djqiang (GitHub account name)/gitdemo (project name). Git

Tip error Message: Fatal:remote origin already exists.

The solution is as follows:

1. First enter GIT remote RM origin

2. Then enter $ git remote add origin git@github.com:djqiang/gitdemo.git will not error.

3. If you enter GIT remote RM origin or an error, error:could not remove config section ' Remote.origin '. We need to modify the contents of the Gitconfig file

4. Find your GitHub installation path, mine is C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\ etc

5, find a file named Gitconfig, open it to the [remote "origin"] that line to delete the good.

If you enter $ ssh-t git@github.com
Error message: Permission denied (PublicKey). Because the newly generated key cannot join SSH, it will cause the connection to not be on GitHub.

The solution is as follows:

1, first enter $ ssh-agent, and then enter $ Ssh-add ~/.ssh/id_key, so you can.

2, if still do not, enter Ssh-add ~/.ssh/id_key command after the error could not open a connection to your authentication agent. The workaround is key with the Git GUI SSH tool Generated, so that when the key is stored directly in SSH, do not need to ssh-add command to join, and other user,token and other configurations are done with the command line.

3, it is best to check if you copy the contents of the Id_rsa.pub file there is no extra space or blank lines, some editors will help you add these.

If you enter a GIT push origin master

Tip error message: error:failed to push som refs to ....

The solution is as follows:

1. First enter the GIT pull Origin master//start the remote server github file down

2. Then enter $ GIT push origin master

3. If an error occurs 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 the git remote add origingit@github.com:djqiang/gitdemo.git

The process of using 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 Readme file
$ git commit-m ' first commit '//submit update and Comment message "First commit"
$ git Remote add origin git@github.com:defnngj/hello-world.git//Connect to a long-distance GitHub project
$ GIT push-u origin master//update local project to GitHub project

Gitconfig configuration file

Git has a tool called Git config that allows you to get and set configuration variables that control all aspects of Git's look and operation. These variables can be stored in three different locations:
1./etc/gitconfig file: Contains values that apply to all users of the system and to all libraries. If you pass the parameter option '--system ' to git config, it will explicitly read and write this file.
2.~/.gitconfig file: Specific to your users. You can make git read or write this particular file by passing the--global option.
3. config file (i.e.. git/config) in the Git directory: Regardless of what library you are currently using, point to that single library. Each level overrides the value of the previous level. Therefore, the value in. Git/config overrides the same value in the/etc/gitconfig.
In Windows systems, Git looks for. gitconfig files in the $home directory (for most people, under C:\Documents and Settings\ $USER). It will also look for/etc/gitconfig, although it is relative to the Msys root directory. This could be anywhere you decide to install git when you run Setup in Windows.

Configuration related information:

2.1 The first thing to do when you install Git is to set your user name and e-mail address. This is important because each git commit uses that information. It is permanently embedded in your submission:

$ git config--global user.name "John Doe"

$ git config--global user.email johndoe@example.com

2.2 Your editor (Your editor)

Now that your logo is 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 either 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 there:

$ git config--list

You can also look at the current value of a particular keyword that git believes to be, using the following command git config {key}:

$ git config user.name

2.4 Get Assistance (Getting help)

If you need help with Git, there are three ways to get the manual page (manpage) Help for any git command:

$ git help <verb>

$ git <verb>--help

$ mans git-<verb>

For example, you can run the following command to get the manual pages Help for the Config command:

$ git help config

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.