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

How to use Github under Linux system

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces "how to use Github under the Linux system". In the daily operation, I believe that many people have doubts about how to use Github under the Linux system. The editor consulted all kinds of materials and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubt of "how to use Github under the Linux system". Next, please follow the editor to study!

1.

Install git:

The code is as follows:

Sudo apt-get install git-core git-gui git-doc

two。

Register an account with https://github.com/, which will be used when the client logs in later.

3.

Install SSH Key on the client side to facilitate us to log in securely on the client side:

The code is as follows:

Cd / .ssh

If you prompt "there is no file or directory", then you have not generated SSH Key before, so skip to step 4, otherwise save the previous SSH Key:

The code is as follows:

Ls

Mkdir key_backup

Cp id_rsa* key_backup

Rm id_rsa

4.

The code is as follows:

Ssh-keygen-t rsa-C "your_email@youremail.com"

Note: you need to fill in your registered mailbox.

Then we will ask where to save the key. By default, we will always enter it.

5.

Log in to githut, have an Account Settings, click SSH public Key, then open the id_rsa.pub file generated in step 4, copy it all to the key column, title can take it at will, click Add Key

6.

Then let's test the connection:

The code is as follows:

Ssh-T git@github.com

The first time there will be an error message, ignore him, type yes, and then, if all goes well, there should be "Hi your registered user name! You've successfully authenticated, but GitHub does not provide shell access." Indicates that you are properly connected to the github

7.

The code is as follows:

Git config-- global user.name "your own name, may not be a registered name"

Git config-- global user.email "your own mailbox, which may not be a registered mailbox name"

Git config-- the registered name of global github.user github

Git config-global github.token XXX

Note: XXX is obtained as follows:

Log in to github and have an Account Settings. Click "Account Admin" in it, where API Token is the above XXX.

Now that we can use github, let's create a Repository

8.

Open https://github.com/repositories/new, fill in the project name, description, home page, etc., click "Create Reopsitory", and a Repository is created in our account, but it is empty. Let's add something to it:

9.

The code is as follows:

Mkdir XXX

(XXX is the local folder to synchronize with github)

The code is as follows:

Cd XXX

Git init

Touch README

(as an example, let's synchronize the README here to the Repository above)

The code is as follows:

Git and README

Git commit-m 'XXXXXXXXx'

(XXX is the comment you added during this synchronization, which is convenient for future tracking.)

The code is as follows:

Git remote add origin git@github.com:XXX/YYY.git

Note: XXX is your github registration name, and YYY is the Repository name you just created

The code is as follows:

Git push origin master

When you are done, you will have the README of check in in your Repository.

10.

Update Fil

The code is as follows:

Vi README

Automatic commit changes to files

The code is as follows:

Git commit-a

Update to remote

The code is as follows:

Git push origin master

11.

Create and merge branches

The code is as follows:

Git branch

Shows that the current branch is master

The code is as follows:

Git branch new-feature

Create a branch

The code is as follows:

Git checkout new-feature

Switch to a new branch

The code is as follows:

Vi page_cache.inc.php

The code is as follows:

Git add page_cache.inc.php

Commit to local GIT

The code is as follows:

Git commit-a-m "added initial version of page cache"

Merge to a remote server

The code is as follows:

Git push origin new-feature

If the new-feature branch is mature, I feel it is necessary to merge into master

The code is as follows:

Git checkout master

Git merge new-feature

Git branch

Git push

Then the code of new-feature is also merged in master

Log in to GitHub and you can see the branching options under "Switch Branches":

At this point, the study on "how to use Github under the Linux system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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