1. Create github account
2. Create ssh
3. Use secret key to connect to github
4. Create a project
5. Upload the code to github
6. Update after modification
Create a github account
Address https://github.com/ Click sign up
Start Register your
registration is successful start the next step
Two create ssh
Native code and connected github warehouses
opened input terminal cd ~/.ssh
that is to check whether your ssh presence, if present, has the first backup ssh, ssh or the new generation to the another directory.
If it does not exist, directly generate ssh through the default parameters and press Enter all the way.
Generate key: ssh-keygen -t rsa -C [email protected]
(The mailbox is the registered mailbox of github)
Input terminal can pbcopy < ~/.ssh/id_test_rsa.pub
copy your key
can also enter the file path, open your generated id_rsa.pub file Edit Copy
Three use the secret key to connect to github
Log in to github and select Account Settings–> SSH Keys to add ssh
Title: [email protected] (this can be filled in casually, it is recommended to use an email registered email)
Key: Copy your key content here.
After saving the
test on your account with a github not even
open a terminal, type ssh -T [email protected]
returns:
Hi shiersimon! You've successfully authenticated, but GitHub does not provide shell access.
indicating success.
If you enter yes in the following cases, it will be successful. For the first time, I only entered y, and found that I want to enter yes in full.
Four create a Project
Log on to github, then click +, select New repository
as shown Repository name: build your own project's name Description: For a brief description of your upload project Public: choice is visible to everyone (general choice is Public, according to their own (Requires selection) Private: You can set the person you specify to be visible
就会进入如下页面...
The following
Initialize this repository with a README: is a file that initializes a README (introduction to the usage of the project) for your project.
Then click Create repository to the next interface, as shown
in Clone or download There will be a git address: https://github.com/shiersimon/Javascript-Tab-Switch.git
This is mine ...
Five upload the code to github
cd 到当前要提交到项目路径
git init //初始化本地仓库
git add . //将代码放到提交区
git commit -m "commit"//提交到本地仓库,并写一些注释 -m 代表注释
git remote add origin [email protected]:shiersimon/Javascript-Tab-Switch.git //连接远程仓库并建了一个名叫:origin的别名
git pull --rebase [email protected]:shiersimon/Javascript-Tab-Switch.git //更新一下
git push -u origin master //将本地仓库的东西提交到地址是origin的地址,master分支下 -u为第一次提交需要创建master分支 ,下次就不需要了。
The following shows that the submission is successful.
Refresh GitHub, you will see that the source code of the project just submitted has been displayed
Six changes and updates
Update the code
Step 1: Check the current git repository status, you can use git status
git status
to see that I changed the index.html page
Step 2: Update all
git add *
Step 3: Then enter git commit -m "update instructions"
git commit -m "更新说明"
The fourth step: first git pull, pull the latest code of the current branch
git pull
Step 5: Push to the remote master branch
git push origin master
Open GitHub has been synchronized