<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          git 常用命令大全

          共 5820字,需瀏覽 12分鐘

           ·

          2021-06-08 17:58

          掃碼關(guān)注我們

          查看更多精彩內(nèi)容


          1.git 常用命令

          1. 常用

          $ git remote add origin [email protected]:yeszao/dofiler.git         # 配置遠(yuǎn)程git版本庫(kù)$ git pull origin master                                          # 下載代碼及快速合并 $ git push origin master                                          # 上傳代碼及快速合并$ git fetch origin                                                # 從遠(yuǎn)程庫(kù)獲取代碼$ git branch                                                      # 顯示所有分支$ git checkout master                                             # 切換到master分支$ git checkout -b dev                                             # 創(chuàng)建并切換到dev分支$ git commit -m "first version"                                   # 提交$ git status                                                      # 查看狀態(tài)$ git log                                                         # 查看提交歷史$ git config --global core.editor vim                             # 設(shè)置默認(rèn)編輯器為vim(git默認(rèn)用nano)$ git config core.ignorecase false                                # 設(shè)置大小寫敏感$ git config --global user.name "YOUR NAME"                       # 設(shè)置用戶名$ git config --global user.email "YOUR EMAIL ADDRESS"             # 設(shè)置郵箱


          2. 別名 alias

          $ git config --global alias.br="branch"                 # 創(chuàng)建/查看本地分支$ git config --global alias.co="checkout"               # 切換分支$ git config --global alias.cb="checkout -b"            # 創(chuàng)建并切換到新分支$ git config --global alias.cm="commit -m"              # 提交$ git config --global alias.st="status"                 # 查看狀態(tài)$ git config --global alias.pullm="pull origin master"  # 拉取分支$ git config --global alias.pushm="push origin master"  # 提交分支$ git config --global alias.log="git log --oneline --graph --decorate --color=always" # 單行、分顏色顯示記錄$ git config --global alias.logg="git log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative" # 復(fù)雜顯示


          3. 創(chuàng)建版本庫(kù)

          $ git clone <url>                 # 克隆遠(yuǎn)程版本庫(kù)$ git init                        # 初始化本地版本庫(kù)


          4. 修改和提交

          $ git status                      # 查看狀態(tài)$ git diff                        # 查看變更內(nèi)容$ git add .                       # 跟蹤所有改動(dòng)過(guò)的文件$ git add <file>                  # 跟蹤指定的文件$ git mv <old> <new>              # 文件改名$ git rm <file>                   # 刪除文件$ git rm --cached <file>          # 停止跟蹤文件但不刪除$ git commit -m “commit message”  # 提交所有更新過(guò)的文件$ git commit --amend              # 修改最后一次提交


          5. 查看歷史

          $ git log                         # 查看提交歷史$ git log -p <file>               # 查看指定文件的提交歷史$ git blame <file>                # 以列表方式查看指定文件的提交歷史


          6. 撤銷

          $ git reset --hard HEAD           # 撤消工作目錄中所有未提交文件的修改內(nèi)容$ git reset --hard <version>      # 撤銷到某個(gè)特定版本$ git checkout HEAD <file>        # 撤消指定的未提交文件的修改內(nèi)容$ git checkout -- <file>          # 同上一個(gè)命令$ git revert <commit>             # 撤消指定的提交分支與標(biāo)簽


          7. 分支與標(biāo)簽

          $ git branch                      # 顯示所有本地分支$ git checkout <branch/tag>       # 切換到指定分支或標(biāo)簽$ git branch <new-branch>         # 創(chuàng)建新分支$ git branch -d <branch>          # 刪除本地分支$ git tag                         # 列出所有本地標(biāo)簽$ git tag <tagname>               # 基于最新提交創(chuàng)建標(biāo)簽$ git tag -a "v1.0" -m "一些說(shuō)明"  # -a指定標(biāo)簽名稱,-m指定標(biāo)簽說(shuō)明$ git tag -d <tagname>            # 刪除標(biāo)簽$ git checkout dev                # 合并特定的commit到dev分支上$ git cherry-pick 62ecb3


          8. 合并與衍合

          $ git merge <branch>              # 合并指定分支到當(dāng)前分支$ git merge --abort               # 取消當(dāng)前合并,重建合并前狀態(tài)$ git merge dev -Xtheirs          # 以合并dev分支到當(dāng)前分支,有沖突則以dev分支為準(zhǔn)$ git rebase <branch>             # 衍合指定分支到當(dāng)前分支


          9. 遠(yuǎn)程操作

          $ git remote -v                   # 查看遠(yuǎn)程版本庫(kù)信息$ git remote show <remote>        # 查看指定遠(yuǎn)程版本庫(kù)信息$ git remote add <remote> <url>   # 添加遠(yuǎn)程版本庫(kù)$ git remote remove <remote>      # 刪除指定的遠(yuǎn)程版本庫(kù)$ git fetch <remote>              # 從遠(yuǎn)程庫(kù)獲取代碼$ git pull <remote> <branch>      # 下載代碼及快速合并$ git push <remote> <branch>      # 上傳代碼及快速合并$ git push <remote> :<branch/tag-name> # 刪除遠(yuǎn)程分支或標(biāo)簽$ git push --tags                 # 上傳所有標(biāo)簽


          10. 打包

          $ git archive --format=zip --output ../file.zip master    # 將master分支打包成file.zip文件,保存在上一級(jí)目錄$ git archive --format=zip --output ../v1.2.zip v1.2      # 打包v1.2標(biāo)簽的文件,保存在上一級(jí)目錄v1.2.zip文件中$ git archive --format=zip v1.2 > ../v1.2.zip             # 作用同上一條命令


          11. 全局和局部配置

          全局配置保存在:$Home/.gitconfig本地倉(cāng)庫(kù)配置保存在:.git/config


          12. 遠(yuǎn)程與本地合并

          $ git init                              # 初始化本地代碼倉(cāng)$ git add .                             # 添加本地代碼$ git commit -m "add local source"      # 提交本地代碼$ git pull origin master                # 下載遠(yuǎn)程代碼$ git merge master                      # 合并master分支$ git push -u origin master             # 上傳代碼

          往期精選


          每個(gè)人都應(yīng)該知道的25個(gè)Git命令

          圖解 | git rebase使用筆記

          Git rebase使用詳解

          搭建服務(wù)器上的GIT并實(shí)現(xiàn)自動(dòng)同步到站點(diǎn)目錄(www)

          免費(fèi)獲取Git GO Java視頻教程

          瀏覽 80
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  免费操逼网 | 日本精品综合网在线视频 | 日日日日日日日日日日日日日日日干 | 欧美日韩aA在线视频 | 免费无码高清 |