git常用命令

1、合并某個(gè)分支的某個(gè)文件

git checkout 分支名 文件路徑?

例:git checkout origin/dev src/component/goods/goodDetail

2、刪除本地分支

git branch -d 分支名

3、刪除遠(yuǎn)程分支

git push origin --delete 分支名

4、本地分支重命名

git branch -m 老的分支名 新的分支名

5、查看已有tag

git tag

6、新建tag

git tag? 新建的tag名

7、新建有備注信息的tag

git tag -a 新建的tag名 -m '備注信息'

8、給指定的commit號打tag

git tag -a 新建的tag名 commit號

9、推送本地某個(gè)tag到遠(yuǎn)程

git push origin tag名

10、推送本地所有tag到遠(yuǎn)程

git push origin --tags

11、刪除本地tag

git tag -d tag名

12、刪除遠(yuǎn)程tag

git push origin :refs/tags/tag名

13、解決Your branch is based on 'origin/xxxx', but the upstream is gone

第一步:git config --get branch.bBranch.remote

>origin

第二步:git config--getbranch.bBranch.merge>refs/heads/aBranch

第三步:git branch --set-upstream-to=origin/bBranch

14、推送新項(xiàng)目到遠(yuǎn)程倉庫

第一步:git init(初試化)

第二步:git config --global user.name "Administrator"(配置用戶信息)

git config --global user.email "admin@example.com"

第三步:git remote add origin 遠(yuǎn)程倉庫地址

15、回退到上一個(gè)版本

git reset --hard HEAD^

16、回退到指定版本

git reset --hard 版本號

17、強(qiáng)拉遠(yuǎn)程,覆蓋本地

git fetch --all

git reset --hard origin/master

18、強(qiáng)推本地到遠(yuǎn)程

git push -f origin master

19、基于commitId創(chuàng)建新的分支

git checkout -b yourNewBranch commitId

20、合并指定的commitId分支代碼

git cherry-pick commitId

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

相關(guān)閱讀更多精彩內(nèi)容

  • 開始: 1) 遠(yuǎn)程倉庫相關(guān)命令 檢出倉庫:$ git clone git://github.com/jquery/...
    草根老張閱讀 924評論 0 50
  • 本文針對初級用戶,從最簡單的講起,但是需要讀者對Git的基本用法有所了解。 Git是開源的分布式版本控制系統(tǒng),...
    Sachie閱讀 1,254評論 0 2
  • 配置 首先是配置帳號信息ssh -T git@github.com # 登陸 github 修改項(xiàng)目中的個(gè)人信息 ...
    guanguans閱讀 822評論 0 3
  • Git有很多優(yōu)勢,其中之一就是遠(yuǎn)程操作非常簡便。本文詳細(xì)介紹5個(gè)Git命令,它們的概念和用法,理解了這些內(nèi)容,你就...
    bondPang閱讀 1,411評論 0 6
  • 查看、添加、提交、刪除、找回,重置修改文件 git help # 顯示command的help git sho...
    Swiftor閱讀 2,212評論 0 2

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