git 創(chuàng)作者
LINUS TORVALDS 同時是linux的創(chuàng)作者
為什么要使用git
1.牛逼的大神都在用
2.完整的版本控制 解決多人協(xié)作問題
3.提高開發(fā)效率
4.同步到github,代碼的積累,讓更多人通過代碼了解你的成長歷程
git 與 github 的關(guān)系
git與github的關(guān)系就像球與球場的關(guān)系
git 安裝
https://git-scm.com/ 官網(wǎng)下載安裝
git 賬號配置
git config --global user.name "yelingkong"
git config --global user.email "zhaowanjun123@gmail.com"
使用list命令查看配置是否成功
git config --list

image.png
git 倉庫
初始化版本庫
git init
添加文件到版本庫
git add
添加描述信息
git commit
查看倉庫狀態(tài)
git status
git 工作流

image.png
遠(yuǎn)程倉庫github
創(chuàng)建SSH key
郵箱賬號為github上的郵箱賬號
ssh-keygen -t rsa -C "zhaowanjun123@gmail.com"
執(zhí)行上面的命令后

image.png
執(zhí)行命令復(fù)制里面的內(nèi)容

image.png
登錄github->setting->SSH keys添加前面復(fù)制的代碼粘貼進(jìn)去

image.png
執(zhí)行下面的代碼查看是否創(chuàng)建成功
ssh -T git@github.com
出現(xiàn)以下代碼即表示創(chuàng)建成功啦

image.png
添加到遠(yuǎn)程倉庫
git remote add origin https://github.com/yelingkong/learn_vue_js
git pull origin master —allow-unrelated-histoies
git push -u origin master
克隆倉庫
git clone https://github.com/yelingkong/learn_vue_js
標(biāo)簽管理
通過標(biāo)簽回滾版本!
查看所有的標(biāo)簽
git tag
創(chuàng)建標(biāo)簽
git tag name
刪除標(biāo)簽
git tag -d name
指定提交消息
git tag -a name -m "comment"
標(biāo)簽發(fā)布
git push origin name
刪除遠(yuǎn)程標(biāo)簽
git push origin :refs/tags/name
分支管理
創(chuàng)建分支
git branch name
查看分支
git branch
切換分支
git checkout name
合并分支
git merge name
刪除分支
git branch -d name
解決版本沖突
返回歷史版本
git reset --hard id
列出版本號
git reflog
多人合作經(jīng)驗
1.多用客戶端少用命令行
2.整理好工作區(qū)
3.搞清楚沖突代碼的原因
4.記得打tag
github上搭建站點
可以在github上搭建站點如下
https://yelingkong.github.io/vue_shop/cart.html
首先github上的代碼需要是網(wǎng)頁代碼
然后創(chuàng)建一個名稱為gh-pages的分支
之后訪問網(wǎng)頁格式為
https://用戶名.github.io/項目名/文件名