[Advanced Operations and Maintenance Knowledge] An article takes you to understand the basic operations of GitHub! (register user + configure ssh-key + create project + create repository + pull code to local + push new code to Github)

This article briefly introduces GitHub. GitHub is a Git repository hosting service. It is currently the largest software warehouse in the world. It has millions of developers and users. It is suitable for your own use. You can share the code files after you upload them. The code files can be cloned by anyone, making it easier for developers to contribute code to open source projects, and they can also pay for private libraries, but after all, they are placed in other people's places, and private libraries are not absolutely safe. Put it in your own code base and use GitLab. Of course, if you are an individual developer or use it in an enterprise, I hope this article can help you!

Table of contents

GitHub use

1. Registered users

Two, configure ssh-key

3. Create a project

Fourth, create a repository

5. Pull the code to the local

6. Push new code to GitHub


GitHub use

1. Registered users

 Search the official website and follow the process to operate

Two, configure ssh-key

Since the code files in the linux system need to be sent to github, you need to make your own linux system and your own github backend without a key to realize code push.

First create ssh private key public key copy public key

[root@Gitlab ~]# ssh-keygen -t rsa -C "[email protected]"    #填自己注册github的邮箱
[root@Gitlab ~]# cat .ssh/id_rsa.pub     #复制公钥

login account 

Key-free under Linux test, you need to enter yes for the first time, and you don’t need to enter it later

[root@Gitlab ~]# ssh -T [email protected]
......
Are you sure you want to continue connecting (yes/no)? yes
......
Hi bosskoten! You've successfully authenticated, but GitHub does not provide shell access.
[root@Gitlab ~]# ssh -T [email protected]
Hi bosskoten! You've successfully authenticated, but GitHub does not provide shell access.

3. Create a project

Create in the lower right corner can create 

There will be title, author, and status in the project for us to write, so that we can check the progress and completion status. Click the plus sign to add them in turn. After writing the title, press Enter

drop down check 

select state 

By analogy, multiple tasks can be set

Enter the setting interface 

Make the project public 

Fourth, create a repository

Create a repository repository 

5. Pull the code to the local

Pull the code to the host 

[root@Gitlab git_test]# git pull [email protected]:bosskoten/test.git
warning: no common commits
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From github.com:bosskoten/test
 * branch            HEAD       -> FETCH_HEAD
Merge github.com:bosskoten/test

# Please enter a commit message to explain why this merge is ne
cessary,
# especially if it merges an updated upstream into a topic bran
ch.
#
# Lines starting with '#' will be ignored, and an empty message
 aborts
# the commit.
~                                                              
~                                                              
~                                                              
~                                                              
~                                                              
~                                                              
Merge made by the 'recursive' strategy.
 README.md | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 README.md

The repository content will be found after a successful pull

[root@Gitlab git_test]# cat README.md 
# test
测试

6. Push new code to GitHub

1. Associate Github and submit the code to Github's repository

[root@Gitlab git_test]# git remote add origin [email protected]:bosskoten/test.git
[root@Gitlab git_test]# git push origin master
Counting objects: 12, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (11/11), 1.16 KiB | 0 bytes/s, done.
Total 11 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), done.
remote: 
remote: Create a pull request for 'master' on GitHub by visiting:
remote:      https://github.com/bosskoten/test/pull/new/master
remote: 
To [email protected]:bosskoten/test.git
 * [new branch]      master -> master
[root@Gitlab git_test]# ls
1.txt  dev  dev_test  README.md  test

# 如果是第一次合并分支,可以将其默认设置为上游
git push -u origin <分支名称>   
# 所有分支的代码一键提交到仓库
git push --all origin           

2. Check whether the master branch has push content 


I am koten, with 10 years of experience in operation and maintenance, and I continue to share dry goods in operation and maintenance. Thank you for your reading and attention!

Guess you like

Origin blog.csdn.net/qq_37510195/article/details/130760545
Recommended