git operation (reprint)

git operating procedures (reprint)

1. Platform: Cloud code

2.gitee project creation process

Create a warehouse (choose open source warehouse management below)

3.git team operation

1. The initial install git configure the user name and mailbox

Git initial installation you need to configure the user name and mailbox, otherwise git will prompt: please tell me who you are.

img

You need to run the commands to configure your user name and E-mail:

$ git config --global user.name "zhuxiaohang0310"

$ git config --global user.email "[email protected]"

Note :( Please enter the name of your own set of quotation marks, and your own mailbox) user name and mailbox is used to display your identity and contact details of when git commit code, not github username and mailbox


4.git use ssh keys

git git support https and two transport protocols, github share will link two protocols available:

img

img

Note: git using the https protocol, each pull, push will be prompted to enter a password, use git protocol, then use the ssh key, so eliminating lost password every time trouble

First-time users want to use git git protocol takes about three steps:

A, generating a key pair

Second, set up a remote repository (github paper, for example) on the public

Third, the git git the remote url modify the protocol (more than two steps after the initial setup too, do not need to set up again after use, this step depending on the remote url future projects may be, if in the future other items you will need to https protocol this step)


The generated key pair

Most will choose Git server using SSH public key for authorization. Each user in the system must provide a public key for authorization, if not necessary to generate a. The process of generating public key are similar across all operating systems. First you have to confirm whether or not the machine has a public key.

~ SSH public default stored in the home directory of the account / .ssh directory. Look inside:

$ cd ~/.ssh
$ ls
authorized_keys2  id_dsa       known_hosts config            id_dsa.pub

Look there id_rsa and id_rsa.pub (or id_dsa and id_dsa.pub like a pair of files), there suffix .pub file is the public key, and the other file is the key.

Without these documents, did not even .ssh directory, you can use ssh-keygen to create. The program on Linux / Mac systems provided by the SSH package, and in the Windows package is included in the MSysGit:

$ ssh-keygen -t rsa -C "[email protected]"

Creates a new ssh key using the provided email # Generating public/private rsa key pair.

Enter file in which to save the key (/home/you/.ssh/id_rsa):

Press Enter on the line. Then, you will be prompted to enter a password, as follows (lose a recommended, safer, of course, do not lose the line, should not someone pretending to idle, bored you to modify your code):

Enter same passphrase again: [Type passphrase again]

After over, something like this:

Your public key has been saved in /home/you/.ssh/id_rsa.pub.
The key fingerprint is: # 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db [email protected]

So far, your local key pair is generated.


6. Add your public key to the remote repository (github)

1. Check your public key generated:

$ cat ~/.ssh/id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0X6L1zLL4VHuvGb8aJH3ippTozmReSUzgntvk434aJ/v7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8vR3c8E7CjZN733f5AL8uEYJA+YZevY5UCvEg+umT7PHghKYaJwaCxV7sjYP7Z6V79OMCEAGDNXC26IBMdMgOluQjp6o6j2KAdtRBdCDS/QIU5THQDxJ9lBXjk1fiq9tITo/aXBvjZeD+gH/Apkh/0GbO8VQLiYYmNfqqAHHeXdltORn8N7C9lOa/UW3KM7QdXo6J0GFlBVQeTE/IGqhMS5PMln3 admin@admin-PC

2, login to your github account. Click on your avatar, thenSettings -> 左栏点击 SSH and GPG keys -> 点击 New SSH key

3, and then you copy the public key contents above, paste into the "Key" text field. The title field, own just a name.

4. Click Add key.

After completion of this verification key is not working properly:

$ ssh -T [email protected]

Attempts to ssh to github

If you see:

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

Congratulations, you have successfully set up.


7. Modify the git remote url

Use the command git remote -v view your current remote url

$ git remote -v
origin https://github.com/someaccount/someproject.git (fetch)
origin https://github.com/someaccount/someproject.git (push)

If the result is less than the description of this project is to use the https protocol to access (if the address is the beginning of a git git, said the agreement)

You can login to your github, just like the legend of the beginning of this article, you can see the corresponding ssh protocol your url on it, like this:

img

Copy this link ssh, then use the command git remote set-url to adjust your url.

git remote set-url origin [email protected]:someaccount/someproject.git

Then you can reuse the command git remote -v check whether the url has become ssh address.

Then you can happily use git fetch, git pull, git push, no longer have to enter a password annoying

Reference link: http: //www.tuicool.com/articles/BzUrAvF

(Finish)

Guess you like

Origin www.cnblogs.com/xiaohanga/p/11225898.html