Mac upload project source code to GitHub to modify and update

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 upStart 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)
Insert picture description here

Input terminal can pbcopy < ~/.ssh/id_test_rsa.pubcopy 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.
Insert picture description 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.
Insert picture description here

Four create a Project

Log on to github, then click +, select New repositoryas 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
Insert picture description here
就会进入如下页面...
Insert picture description here



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
Insert picture description here
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  到当前要提交到项目路径

Insert picture description here

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.
Insert picture description here
Refresh GitHub, you will see that the source code of the project just submitted has been displayed
Insert picture description here

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
Insert picture description here
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
Insert picture description here

Published 41 original articles · Likes2 · Visits 1836

Guess you like

Origin blog.csdn.net/weixin_43883485/article/details/104712677
Recommended