gitlab upload projects require public ssh-free interaction, this article describes gitlab setting operation of public and upload the project.
First, create a secret key for
[Root @ localhost ~] # ssh-keygen -t rsa # all the way round to
Second, upload keys
[Root @ localhost ~] # cat ~ / .ssh / id_rsa.pub # View Public Key
Third, upload native code
1, first set up users and mailboxes
[root@localhost opt]# git config --global user.name "root"
[root@localhost opt]# git config --global user.email "[email protected]"
[root@localhost opt]# git config --list
user.name=root
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 an empty Git repository 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, access to branches
# This branch information, you can see in the web interface clon
[root@localhost push_code]# git remote add origin http://192.168.0.8:81/test/hellow.git
5, refresh remote repository branch
[root@localhost push_code]# git fetch origin --prune
# Get all remote branch
# Is now in the master branch
[root@localhost push_code]# git branch -a
0a
* master
remotes/origin/devops
remotes/origin/master
6, submit code
# Submit the file to the local repository
[Root @ localhost push_code] # git add push.txt # Add files
[Root @ localhost push_code] # git commit -m "this is test push" # add a description
[Root @ localhost push_code] # git push origin master # codes to push the master branch
# Pits
[root@localhost push_code]# git push origin master
Username for 'http://192.168.0.8:81': root
Password for 'http://[email protected]:81':
To http://192.168.0.8:81/test/hellow.git
! [rejected] master -> master (non-fast-forward)
error: can not push some of the references to 'http://192.168.0.8:81/test/hellow.git'
Tip: Update was rejected because you are currently submitting the latest remote branch behind its corresponding branch.
Tip: Before push again, the first change combined with the remote (such as 'git pull'). See
Tip: 'git push --help' in 'Note about fast-forwards' section.
# Solution: re-pull remote code repository of information, consistent with the remote repository 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://[email protected]:81':
From http://192.168.0.8:81/test/hellow
* branch HEAD -> FETCH_HEAD
It is up to date!
7, branch switching
[root@localhost push_code]# git checkout devops
Branch devops to track remote branch from the origin of devops.
Switching to a new branch 'devops'
[root@localhost push_code]# git branch -a
* devops
master
remotes/origin/devops
remotes/origin/master
Other branches of the code uploaded same repeating manner to Step 6
8, pulling the specified branch code
-b DevOps clone Git http://192.168.0.8:81/test/hellow.git # -b specified pulling branch code
9, create a branch
git branch slave create slave branch