測試筆記01-Git

Git工具

Git 一個分佈式版本管理工具,

學習資料: https://www.liaoxuefeng.com/wiki/896043488029600/1317161920364578

其中:解決衝突、分支管理策略、Bug分支、Feature分支、多人協作、Rebase暫未學習

git switch 需要git 版本 >= 2.23

Git 提交規範

<type>(<scope>): <subject>
// 空一行
<body>
// 空一行
<footer>

Header部分

type:(必須項)

feat:        A new feature(新增feature)
fix:         A bug fix(修復bug)
docs:        Documentation only changes(僅文檔更改,如README.md)
refactor:    A code change that neither fixes a bug nor adds a feature(代碼重構,沒有新增功能或修復bug)
perf:        A code change that improves performance(優化相關,如提升性能、用戶體驗等)
test:        Adding missing tests or correcting existing tests(測試用例,包括單元測試、集成測試)
build:       Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)(影響構建系統或外部依賴關係的更改(示例範圍:gulp、broccoli、npm))
chore:       Other changes that don't modify src or test files(其他不修改src或測試文件的更改)
style:       Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)(不影響代碼含義的更改(空格、格式、缺少分號等))
ci:          Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)(對ci配置文件和腳本的更改)
revert:      Reverts a previous commit(還原以前的提交)

scope:(非必須)

本次提交影響範圍、功能模塊等

subject::(必須)

本次提交的簡要標題, 不超過50個字符

Body部分(非必須)

詳細描述本次提交

Footer部分(非必須)

  • 不兼容變動:以 BREAKING CHANGE 開頭
  • 關閉Issue:Closes #issue

工具人命令彙總

  1. 初始化本地倉庫: git init

  2. 添加文件到本地暫存區: git add <file>

  3. 將暫存區中的文件提交到本地倉庫: git commit -m <message>

  4. 查看本地倉庫狀態(文件是否被修改):git status

  5. 查看變動信息(查看文件修改內容):git diff

  6. 查看本地倉庫歷史記錄(oneline 簡要輸出, 可以查版本ID):git log <--pretty=oneline>

  7. 本地倉庫回退:git reset --hard <HEAD^ | commit ID>

  8. 記錄每一次操作命令(可以查版本ID):git reflog

  9. 撤銷暫存區(add 之後)的修改:git reset HEAD <file>

  10. 丟棄工作區(未add 之前)的修改:git checkout -- <file>

  11. 設置遠程倉庫:git remote add origin https://gitee.com/zy7y/learngit.git

  12. 推送到遠程倉庫(並將本地master與遠程master關聯):git push -u origin master | git push origin master

  13. 從遠程倉庫拉取:git pull <倉庫地址>

  14. 查看遠程倉庫信息:git remote -v

  15. 刪除(解綁關係)遠程倉庫:git remote rm <name>

  16. 從遠程庫克隆(默認是克隆默認分支):git clone https://gitee.com/zy7y/apiAutoTest.git

  17. 克隆指定分支:git clone -b dev https://gitee.com/zy7y/apiAutoTest.git

  18. 查看本地倉庫分支:git branch

  19. 切換分支:git checkout <分支名> or git switch <分支名>

  20. 創建並切換分支:git cehckout -b <分支名> or git switch -c <分支名>

  21. 刪除分支:git branch -d <分支名>

  22. 合併指定分支到當前分支(dev -> master ):git merge <分支名>

    1. dev 分支工作後 add 到暫存區
    2. commit 提交 到倉庫
    3. 切換到 master 分支
    4. git merge dev	# 將 merge 後面的分支 合併到當前分支
    5. 合併完成後刪除 dev 分支 #
    
  23. 查看所有標籤:git tag

  24. 創建標籤:git tag <標籤名>

  25. 指定的版本ID打標籤:git tag <標籤名> <commitID>

  26. 查看標籤信息:git show <標籤名>

  27. 刪除標籤:git tag -d <標籤名>

  28. 推送標籤到遠程:git push origin 標籤名

  29. 刪除遠程倉庫標籤:git push origin :refs/tags/<tagname>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章