1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        git 常用命令大全

        共 5820字,需瀏覽 12分鐘

         ·

        2021-06-08 17:58

        掃碼關注我們

        查看更多精彩內容


        1.git 常用命令

        1. 常用

        $ git remote add origin [email protected]:yeszao/dofiler.git         # 配置遠程git版本庫$ git pull origin master                                          # 下載代碼及快速合并 $ git push origin master                                          # 上傳代碼及快速合并$ git fetch origin                                                # 從遠程庫獲取代碼$ 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                             # 設置默認編輯器為vim(git默認用nano)$ git config core.ignorecase false                                # 設置大小寫敏感$ git config --global user.name "YOUR NAME"                       # 設置用戶名$ git config --global user.email "YOUR EMAIL ADDRESS"             # 設置郵箱


        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" # 復雜顯示


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

        $ git clone <url>                 # 克隆遠程版本庫$ git init                        # 初始化本地版本庫


        4. 修改和提交

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


        5. 查看歷史

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


        6. 撤銷

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


        7. 分支與標簽

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


        8. 合并與衍合

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


        9. 遠程操作

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


        10. 打包

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


        11. 全局和局部配置

        全局配置保存在:$Home/.gitconfig本地倉庫配置保存在:.git/config


        12. 遠程與本地合并

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

        往期精選


        每個人都應該知道的25個Git命令

        圖解 | git rebase使用筆記

        Git rebase使用詳解

        搭建服務器上的GIT并實現自動同步到站點目錄(www)

        免費獲取Git GO Java視頻教程

        瀏覽 80
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        分享
        舉報
        評論
        圖片
        表情
        推薦
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        分享
        舉報
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            九九视频免费观看 | 欧美精品秘 入口蜜桃 | 色色影音先锋 | 亚洲va久久久噜噜噜久久男同 | 一起操在线视频 | 日本h电影 | 色婷丁香 | 日本三级三级欧美三级 | 国产性猛交╳XXX乱大交 | 久久人人爽av亚洲精品天堂牛牛 |