Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Gitlab uploads public key and project code

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Uploading a project on gitlab requires no interaction with ssh public key. This document describes how to set the public key on gitlab and upload the project.

First, create a key pair

[root@localhost] # ssh-keygen-t rsa # you can enter all the way.

2. Upload secret key

[root@localhost] # cat ~ / .ssh/id_rsa.pub # View the public key

3. Upload local code

1. Set up users and mailboxes first

[root@localhost opt] # git config-- global user.name "root"

[root@localhost opt] # git config-- global user.email "w135xxxxx@qq.com"

[root@localhost opt] # git config-- list

User.name=root

User.email=w135xxxx@qq.com

2. Create a local code repository

[root@localhost opt] # mkdir push_code

[root@localhost opt] # cd push_code/

3. Initialize the warehouse

[root@localhost push_code] # git init

Initialize the empty Git version library in / opt/pull_code/.git/

[root@localhost push_code] # echo "this is test push code" > push.txt

[root@localhost push_code] # ls

Pull.txt

4. Get the branch

# this branch information can be found in the web interface clon

[root@localhost push_code] # git remote add origin http://192.168.0.8:81/test/hellow.git

5. Refresh the remote warehouse branch

[root@localhost push_code] # git fetch origin-- prune

# get all remote branches

# is now in the master branch

[root@localhost push_code] # git branch-a

0a

Master

Remotes/origin/devops

Remotes/origin/master

6. Submit the code

# submit the document to the local warehouse

[root@localhost push_code] # git add push.txt # add File

[root@localhost push_code] # git commit-m "this is test push" # add instructions

[root@localhost push_code] # git push origin master # push code to master branch

# Xiaopeng

[root@localhost push_code] # git push origin master

Username for 'http://192.168.0.8:81': root

Password for 'http://root@192.168.0.8:81':

To http://192.168.0.8:81/test/hellow.git

! [rejected] master-> master (non-fast-forward)

Error: unable to push some references to 'http://192.168.0.8:81/test/hellow.git'

Tip: updates are rejected because the latest submission of your current branch lags behind its corresponding remote branch.

Tip: merge with remote changes (such as' git pull') before pushing again. See for details

Hint: 'git push-- the' Note about fast-forwards' section in help'.

# solution: pull the remote code warehouse information again and keep it consistent with the remote warehouse code information

[root@localhost push_code] # git pull http://192.168.0.8:81/test/hellow.git

Username for 'http://192.168.0.8:81': root

Password for 'http://root@192.168.0.8:81':

From http://192.168.0.8:81/test/hellow

Branch HEAD-> FETCH_HEAD

It's already up to date!

7. Switch branches

[root@localhost push_code] # git checkout devops

The branch devops is set to track the remote branch devops from origin.

Switch to a new branch 'devops'

[root@localhost push_code] # git branch-a

Devops

Master

Remotes/origin/devops

Remotes/origin/master

Other branches upload codes in the same way and repeat step 6.

8. Pull the specified branch code

Git clone-b devops http://192.168.0.8:81/test/hellow.git #-b specifies the code to pull the branch

9. Create a branch

Git branch slave creates slave branch

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report