本篇內(nèi)容介紹了“git 常用命令有哪些”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
建湖ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為成都創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!
1.git 常用命令
$ git remote add origin git@github.com: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 # 設(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)建版本庫
$ git clone <url> # 克隆遠程版本庫$ git init # 初始化本地版本庫
4. 修改和提交
$ git status # 查看狀態(tài)$ git diff # 查看變更內(nèi)容$ 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 # 撤消工作目錄中所有未提交文件的修改內(nèi)容$ git reset --hard <version> # 撤銷到某個特定版本$ git checkout HEAD <file> # 撤消指定的未提交文件的修改內(nèi)容$ git checkout -- <file> # 同上一個命令$ 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 "一些說明" # -a指定標(biāo)簽名稱,-m指定標(biāo)簽說明$ 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. 遠程操作
$ 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># 刪除遠程分支或標(biāo)簽$ git push --tags # 上傳所有標(biāo)簽
10. 打包
$ git archive --format=zip --output ../file.zip master # 將master分支打包成file.zip文件,保存在上一級目錄 $ git archive --format=zip --output ../v1.2.zip v1.2 # 打包v1.2標(biāo)簽的文件,保存在上一級目錄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 # 上傳代碼
“git 常用命令有哪些”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!
當(dāng)前名稱:git常用命令有哪些
網(wǎng)頁鏈接:http://chinadenli.net/article6/giedig.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動態(tài)網(wǎng)站、微信小程序、搜索引擎優(yōu)化、自適應(yīng)網(wǎng)站、面包屑導(dǎo)航、網(wǎng)站排名
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)