The method of using GitHub under the Linux command line
Today, I would like to share with you about the method of using GitHub under the Linux command line. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
1. Sign up for github account
two。 Create a ssh key
Cd ~
Ssh-keygen-t rsa-C your_email@example.com
The id_rsa.pub file is generated under ~ / .ssh /, and SSH and GPG keys-on the github website
> New SSH Keys, write the title casually, you can write the name of the computer, and change the contents of the id_rsa.pub
Paste in key, and finally click Add SSH Key.
3. Open the terminal
Ssh-T git@github.com
If you prompt Permission denied (publickey) for this step, execute ssh-keygen-t rsa
-b 4096-C "your_email@example.com" to regenerate key, a prompt appears indicating that the positive
Often connect to github
Hi ganchunsheng! You've successfully authenticated, but GitHub does
Not provide shell access.
4. Create a warehouse on github
Upload the code as follows:
Git init # initialization
Git add. # initialize the local warehouse
Git commit-m "first commit" # annotated and submitted to the local warehouse
Git remote add origin https://github.com/xxxx/test.git # connects to the remote warehouse
Git push-u origin master # submits things from the local warehouse to the master branch
5. Download the code
Master Branch:
Git clone https://github.com/xxxx/test.git # xxxx is the user name
Include subbranches:
Git clone-- recursive https://github.com/xxxx/test.git
6. common problem
(1) error prompt: fatal: remote origin already exists. Solution:
Git remote rm origin
(2) git is not initialized
* Please tell me who you are.
Run
Git config-global user.email "you@example.com"
Git config-global user.name "Your Name"
Solution:
Git config-global user.name "your_email"
Config-global user.email your_email@example.com
These are all the contents of this article entitled "how to use GitHub under the Linux Command Line". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.