Git實(shí)用命令

config

  • 配置用戶名和郵箱
    git config --global user.name "username"
    git config --global user.email "mailbolx@163.com"
  • git配置代理(看ss配置)
    git config --global http.proxy 'socks5://127.0.0.1:1080' git config --global https.proxy 'socks5://127.0.0.1:1080'
  • 取消代理
    git config --global --unset http.proxy
  • git打開顏色開關(guān)
    git config --global color.ui true

branch

  • 設(shè)置本地dev分支track遠(yuǎn)程分支origin/master
    git branch -u origin/master dev
  • 切到上一個(gè)工作分子
    git checkout -
  • 查看本地分支track的遠(yuǎn)程分支
    git branch -vv
  • checkout遠(yuǎn)程分支
    git checkout -t origin/dev //-t參數(shù), 創(chuàng)建和遠(yuǎn)程分支一樣名字的本地分支
  • 刪除遠(yuǎn)程分支
    git push [遠(yuǎn)程名] :[分支名]
    git push origin :serverfix

commit

  • 獲取兩個(gè)branch/commit (分支 / 提交) 共同的祖先
    git merge-base commit1 commit2
  • 暫存提交/簽出暫存
    git stash/git stash pop
  • 合并多次提交,生成patch
    git diff HEAD~2..HEAD > my-patch.diff git format-patch HEAD~2..HEAD --stdout > changes.patch git format-patch -x --stdout > patch-ddmmyyy.patch git diff tag1 tag2 > the-patch.diff
  • 查看改變的文件列表
    git diff tag1 tag2 --stat
  • 僅查看指定文件/文件夾改變
    git log -- "some file/dir"
    git diff tag1 tag2 -- some/file/name

tag

  • 在當(dāng)前位置添加tag
    git tag -a v1.4 -m "v1.4"
  • 為commit添加tag
    git tag -a v1.2 9fceb02
  • 推送tag到遠(yuǎn)程分支
    git push origin --tags
    git push origin 標(biāo)簽名
  • 刪除本地標(biāo)簽:
    git tag -d 標(biāo)簽名
  • 刪除遠(yuǎn)程標(biāo)簽:
    git push origin :refs/tags/標(biāo)簽名

submodule

  • 添加submodule
    git submodule add https://github.com/hexojs/hexo-theme-light.git themes/light git commit -am "add submodule" git submodule init git submodule update
最后編輯于
?著作權(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)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

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

  • 本片內(nèi)容轉(zhuǎn)自CSDN http://blog.csdn.net/ithomer/article/details/7...
    五娃兒閱讀 5,046評(píng)論 2 87
  • git常用命令 GIT常用命令備忘:http://stormzhang.com/git/2014/01/27/gi...
    新篇章閱讀 8,872評(píng)論 1 26
  • Add & Commit git init 初始化一個(gè) Git 倉(cāng)庫(kù)(repository),即把當(dāng)前所在目錄變成...
    冬絮閱讀 5,133評(píng)論 0 9
  • 一年級(jí)的孩子剛剛?cè)胄?,不適應(yīng)學(xué)校的住宿生活,是特別正常的事情。 家長(zhǎng)們的不舍和焦慮,也是完全可以理解的。但是親愛(ài)的...
    心若已止水閱讀 664評(píng)論 2 5
  • 本文主要沿著以下三個(gè)方向來(lái)解開solr使用之謎,讓大家使用solr跟使用mysql一樣簡(jiǎn)單方便,安裝和介紹部分已經(jīng)...
    meng_philip123閱讀 3,034評(píng)論 1 4

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