[Git] GIT installation and GitLab configuration and use

@ TOC

One, install git

  1. Download git client git download address

Two, configure gitlab

ps: The first time you generate an ssh key, skip to the third step directly

  1. Check if the SSH key exists

$ ls ~/.ssh
Insert picture description here
If the output content contains (where id_rsa is the private key, id_rsa.pub is the public key), continue to step 2

  1. Open key

cat ~/.ssh/id_rsa.pub
copy the key starting with ssh-rsa, go to step 5

  1. Generate SSH keys

ssh-keygen -t rsa -C'[email protected]'
Note: After the execution is completed, there will be a series of commands prompting for the password, just press Enter

  1. View key

Refer to the second step

  1. Configure gitlab's ssh key

Click: Avatar -> Settings -> SSH Keys
configuration: 1. Copy the ssh key into the key input box on the right
2. The key format is correct, the title will be generated by itself, you don’t need to change it
3. Click Add key after setting

  1. Test configuration is successful

ssh -T [email protected]
shows: Welcome to GitLab, @jesse.tang! The configuration is successful

Three, create your own warehouse

  1. New warehouse

Click new project to display the following interface
Insert picture description here
. Note here: The project name must be the same as your local project name, otherwise the upload will not be possible.

Fourth, upload the library

  1. clone project to local

git clone http://IP:port/mars/auto_test.git
touch README.md
git add README.md
git commit -m “add README”
git push -u origin master

  1. Submit local code

1. Initialize git: git init
2. View uncommitted files: git status (the red words are uncommitted and modified)
3. Temporary files: git add.
4. Submit files: git commit -m "Submit to local"
5. Submit server: git push origin master

Five, configuration errors

错误:Permission denied (publickey).

The test configuration passed: ssh -T [email protected]
An error occurred: [email protected]: Permission denied (publickey).
Reason: git@my company git domain address
Solution: ssh -T [email protected] (assuming (The company git domain name is www.git.com)

Guess you like

Origin blog.csdn.net/m0_46537958/article/details/107405963