Foreword
1: First of all you need to know github and git What are they? (In simple terms github is the world's largest gay dating site, git is a tool to deepen the friendship and bond of a joke, not really)
github: foreign hosting a free open-source code for the site, each registered user has a dedicated warehouse personal (individual warehouse may be simply understood as QQ space)
git: the most popular distributed version control system (like SVN, lighter, more convenient, more conducive to collaborative development)
2: GitHub and git What is the connection between it?
https://www.cnblogs.com/jiqing9006/p/5584848.html
Seven steps
①: Register a github account
https://jingyan.baidu.com/article/455a9950abe0ada167277864.html
②: official website to download and install git
③: Use git commands to configure the user name and mailbox
git config --global user.name "your user name" (fill in the registration github username)
git config --global user.email "your mail" (fill in the registration github mailbox)
Note: There are following figure tips when submitting the code to show that you have not yet configured user name and mailbox, you can enter the above code configuration
④: Use the command git git clone " your project address" clone remote repository (equivalent to the code on github download to a local)
Above "your project address" is our github newly created project addresses the
The address has two kinds of formats, respectively, http and the SSH , the upper right corner of FIG Use SSH or Use HTTPS to switch the address
After you create a project to see if shown below, illustrates just created a warehouse but not uploaded any project files (the equivalent of a file is not empty of any file folder)
If you see the figure below, show that you have projects, without having to recreate
When you enter the command git clone " your project address " has prompted the following figure after warning
This tells you download an empty warehouse, because currently there is no any document (can ignore the warning and continue to operate below)
⑤: Use git git add command to add files
New on the desktop a html file and open with any editor (the file contents optional, does not affect the operation)
打开git bash(就是你刚安装好的git)输入命令 git add,若有下图提示没有找到文件,说明你路径有问题
需要先进入该文件所在路径,cd 你的路径
若还有下图提示,说明你输入的命令有误,使用 git add "你的文件名字"
此时文件没有提交到github,只是把文件从工作区提交到stage(暂存区)
⑥:使用git命令git commit -m "文件描述" 提交文件
这里的文件描述必须要有,否则无法提交(根据你提交的文件类型和内容可自行定义文字描述)
此时文件没有被提交到github,只是把文件从stage(暂存区)提交到master(当前分支)
⑦:使用git命令git push把本地项目文件提交到github
直接使用git push提交文件即可。如果你想提交到你的github分支,使用git push origin master(master为分支名字,一般默认master)
此时才真正把项目文件从master(当前分支)提交到github仓库
补充:可能你对git提交文件感到疑惑,为什么要提交3次,我们先来看张图
git add 把文件从工作区提交到stage(暂存区)
git commit 把文件从stage(暂存区)提交到master(当前分支)
git push 把文件从master(当前分支)提交到github
如果想学习git更多相关知识,可参考廖大神写的git教程
https://www.liaoxuefeng.com/wiki/896043488029600/896067008724000