Ubuntu system How to install and configure Git

Source: Internet
Author: User
Tags using git git clone rekey

One, git installation:

1, the binary mode installation:

$ sudo apt-get install Git-core

Once the installation is complete, enter git in the terminal to see the relevant commands. If you just need to use git to manage your local code, you can use it now. If you need to combine with a project on GitHub, there are other things to do.

2. GitHub Account Application

If you just need to copy the code of interest on GitHub to the local, make your own modifications, instead of sharing the publication, it doesn't matter if you don't apply for an account, just need git clone code locally. $ git clone git://IP work (working directory name).

I downloaded the Https://github.com/narendraprasath/Word-Segmentation-in-NLP-Python, as long as this command can: Git clone git://github.com/ Narendraprasath/word-segmentation-in-nlp-python

After all, using GitHub is for the purpose of open source, first go to github.com to register an account.

3, create a local folder, and then do some initialization of global variables

$ git config--global user.name = "User name or User ID"

$ git config--global user.email = " Mailbox"

These two options are automatically added to your code during future use.

4. Create a public key for authentication

This is a more complex and confusing place for most people, because git accesses the repository through SSH, so you need to create a validation file locally. Using the command: $ ssh-keygen-c "you email [email protected]"-t RSA will establish the corresponding key file under the user directory ~/.ssh/. You can use the $ ssh-v [email protected] command to test whether the link is unblocked.

5. Upload Public key

Select Account Settings in the upper-right corner of the github.com interface and select SSH public Keys to select New Add.

Title can be arbitrarily named, the content of Key is copied from ~/.ssh/id_rsa.pub content, after completion, you can use ssh-v [email protected] to test.

I'm not even on GitHub, and I'm having the following error:

Openssh_7.2p2 ubuntu-4ubuntu1, OpenSSL 1.0.2g-fips 1 Mar 2016
Debug1:reading Configuration Data/etc/ssh/ssh_config
DEBUG1:/etc/ssh/ssh_config line 19:applying options for *
Debug1:connecting to github.com [192.30.252.131] Port 22.
Debug1:connection established.
debug1:permanently_set_uid:0/0
Debug1:identity File/root/.ssh/id_rsa Type 1
Debug1:key_load_public:No such file or directory
Debug1:identity File/root/.ssh/id_rsa-cert type-1
Debug1:key_load_public:No such file or directory
Debug1:identity FILE/ROOT/.SSH/ID_DSA type-1
Debug1:key_load_public:No such file or directory
Debug1:identity File/root/.ssh/id_dsa-cert type-1
Debug1:key_load_public:No such file or directory
Debug1:identity FILE/ROOT/.SSH/ID_ECDSA type-1
Debug1:key_load_public:No such file or directory
Debug1:identity File/root/.ssh/id_ecdsa-cert type-1
Debug1:key_load_public:No such file or directory
Debug1:identity file/root/.ssh/id_ed25519 type-1
Debug1:key_load_public:No such file or directory
Debug1:identity File/root/.ssh/id_ed25519-cert type-1
debug1:enabling compatibility Mode for Protocol 2.0
Debug1:local Version string Ssh-2.0-openssh_7.2p2 ubuntu-4ubuntu1
Debug1:remote Protocol version 2.0, Remote software version libssh-0.7.0
Debug1:no match:libssh-0.7.0
Debug1:authenticating to github.com:22 as ' git '
Debug1:ssh2_msg_kexinit sent
Debug1:ssh2_msg_kexinit received
Debug1:kex:algorithm: [Email protected]
Debug1:kex:host Key Algorithm:ssh-rsa
debug1:kex:server->client cipher: [email protected] MAC: <implicit> compression:none
Debug1:kex:client->server cipher: [email protected] MAC: <implicit> compression:none
Debug1:expecting ssh2_msg_kex_ecdh_reply
Debug1:server host Key:ssh-rsa Sha256:nthbg6kxupjwgl7e1igocspromtxdcarlvikw6e5sy8
Debug1:host ' github.com ' is known and matches the RSA Host key.
Debug1:found Key In/root/.ssh/known_hosts:5
Warning:permanently added the RSA host key for IP address ' 192.30.252.131 ' to the list of known hosts.
Debug1:rekey after 134217728 blocks
Debug1:ssh2_msg_newkeys sent
Debug1:expecting Ssh2_msg_newkeys
Debug1:rekey after 134217728 blocks
Debug1:ssh2_msg_newkeys received
Debug1:ssh2_msg_service_accept received
Debug1:authentications that can Continue:publickey
Debug1:next Authentication Method:publickey
debug1:offering RSA Public key: \342\200\[email protected]\342\200\231
Debug1:server accepts Key:pkalg ssh-rsa Blen 279
Sign_and_send_pubkey:signing Failed:agent refused operation
debug1:offering RSA Public Key:/root/.ssh/id_rsa
Debug1:authentications that can Continue:publickey
Debug1:trying private key:/ROOT/.SSH/ID_DSA
Debug1:trying private key:/ROOT/.SSH/ID_ECDSA
Debug1:trying private key:/root/.ssh/id_ed25519
Debug1:no more authentication methods to try.
Permission denied (PublicKey).

Then I found the problem on the understanding:

If you have ever had this problem, I have a solution
First, clear all the Key-pair
Ssh-add-d
Rm-r ~/.ssh
Delete your public-key on GitHub

Regenerate SSH key pair
Ssh-keygen-t rsa-c "[Email protected]"
Chmod 0700 ~/.ssh
chmod 0600 ~/.ssh/id_rsa*

Next normal operation
Add the public key Public-key on GitHub:
1. First run Xclip-sel C ~/.ssh/id_rsa.pub on your terminal copy the public key contents to the Clipboard
2. When you add a public key on GitHub, you can copy it directly
3. Save

Test:
In terminal ssh-t [email protected] successful, the following message appears

Hi 1056739724! You've successfully authenticated, but GitHub does not provide shell access.

The second time, there was a problem:

Warning:permanently added the RSA host key for IP address ' 192.30.252.130 ' to the list of known hosts.
Sign_and_send_pubkey:signing Failed:agent refused operation
Permission denied (PublicKey).

This is the answer.

https://help.github.com/articles/error-agent-admitted-failure-to-sign/

Second, git configuration and use

Using GitHub to manage your projects, you can follow the steps below

1. Building a remote warehouse

After you create your account on Github, click New Repository to fill in some information about the warehouse, such as the name of the warehouse, the description, and whether it is public. Once setup is complete, click Create Repository to build a new warehouse. For example, establish OLSR.

2. Build a local warehouse

In the folder where you need to build the project, use git init to build the repository. When you are finished, you can see that there is one more. Git hidden directory in the file home.

2. Add Files

Use git Add. To make the initial file additions. Over here. Indicates that all the files under the folder are added, and we can also specify the file to be added.

If you enter Git remote add origin [email protected]:d Jqiang (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 the GIT remote add Origin [email protected]:d jqiang/gitdemo.git will not error!

3. Submit Documents

With git commit-m ' comment ' submission, you can submit your edits.

4. Delete or add GitHub remote sources

Git remote Add origin https://github.com/Git-Elite/CodeBase.git//Blue part for GitHub hosted warehouse address

5. Submit to GitHub Warehouse

Git push-u Origin Master

Error: Tip: The update is rejected because the remote repository contains commits that you do not already exist locally. This is usually due to another hint: a repository has been pushed to the reference. Before you push again, you may need to consolidate the remote change prompt first: (such as ' git pull ... '). Tip: See the ' Note about Fast-forwards ' section in ' Git Push--help '. Force push GIT push Origin +master

This is how Ubuntu installs and configures Git, and you need to build a github repository before using Git to manage your Linux projects.

Ubuntu system How to install and configure Git

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.