Git使用

拉取代碼

1.克隆代碼

git clone www.xxxxss.git

2.查看所有分支

git branch -a

3.選擇遠(yuǎn)程分支,并同步至本地

git checkout --track origin/分支名 (比如 origin/dev)

提交代碼

4.查看本地狀態(tài)

git status

5.添加文件

git add .

6.輸入修改信息

git commit -m"吧啦吧啦吧啦"

7.提交前同步遠(yuǎn)程代碼

git pull

7.提交修改至遠(yuǎn)程

git push

分支操作

1.創(chuàng)建本地分支

$ git checkout -b dev

2.創(chuàng)建遠(yuǎn)程分支

$ git push origin dev:dev //前面是遠(yuǎn)程分支名 后面是本地分支名

3.刪除本地分支

$ git branch -D dev

4.刪除遠(yuǎn)程分支

$ git push origin --delete test
or
git push origin :test //推一個(gè)空分支 相當(dāng)于刪除

替換遠(yuǎn)程倉(cāng)庫(kù)地址

第一步

git remote -v  #查看遠(yuǎn)端地址
git remote #查看遠(yuǎn)端倉(cāng)庫(kù)名
git remote set-url origin https://gitee.com/xx/xx.git (新地址)

第二步

git pull origin master --allow-unrelated-histories   強(qiáng)制合并 (可能會(huì)有沖突,手動(dòng)解決)

第三步

git add .
git commit -m"xxx"
git push

版本回退

git log
git reset --hard f496a9e3442ea660c10ae229c719d4e13e4ff70f
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容