這里記錄一下git
常用的命令:
作為一個(gè)版本控制的軟件蟹肘,對于
- 版本管理
git 的版本管理主要靠HEAD
指向的commitId
來改變祟同,是針對于一個(gè)branch
而言,每個(gè)版本的內(nèi)容除文件外還有日志git log
git reset --hard commitId // 版本的切換
git reflog // 可以查看向后的commitId
- 分支的管理
git branch YourBranch // 創(chuàng)建分支MyBranch
git branch -d YourBranch // 刪除分支MyBranch
git checkout YourBranch // 切換分支
// git checkout -b YourBranch
git merge Branch // 合并分支,需要解決沖突
注: 合并分支時(shí)可以 master->dev运嗜,也可以 dev->master 只需要解決沖突一次即可
- remote,local的管理
查看遠(yuǎn)程庫信息
git remote -v
遠(yuǎn)程倉庫的名字一般為:origin
git clone https:url // 將遠(yuǎn)程倉庫克隆到本地,此時(shí)自動(dòng)構(gòu)建master分支與遠(yuǎn)程master分支關(guān)聯(lián)
git remote add origin git@github.com:xxxx/xxxx.git // 關(guān)聯(lián)遠(yuǎn)程倉庫
git push origin master // 將本地master分支提交到遠(yuǎn)程倉庫master分支
創(chuàng)建遠(yuǎn)程分支 dev 到本地
git checkout -b dev origin/dev
將本地分支與遠(yuǎn)程分支建立鏈接悯舟,以便
git pull
git branch --set-upstream-to=origin/dev dev
ref: 廖雪峰的git教程
更多內(nèi)容可關(guān)注本人博客:老香椿(https://laoxiangchun.cn/)