[TOC]
## 實用文章
* [放弃使用Merge,开心拥抱Rebase](https://juejin.cn/post/7273018561962377216)
* [基于Gitlab Runner 快速实现 Gitlab 自动部署](https://juejin.cn/post/7273026558398365736)
## 使用 SSH 的一點紀錄
* 一開始是因為要一直輸入密碼很麻煩,就想說使用 SSH 一勞永逸
## 過程
* 使用 ssh-keygen 生產 SSH Key
* 
* 將產生的 id_rsa.pub 內容放進 github
* cat /home/kawa/.ssh/id_rsa.pub 取得要貼到 github 的 Key
* 
* 把 github.com 加入白名單的樣子
* ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
* 
* [解決問題的來源網站](https://stackoverflow.com/questions/13363553/git-error-host-key-verification-failed-when-connecting-to-remote-repository)
* 即可不輸入密碼 pull & push(寫的時候還沒推過,應該可以)
### 修改現有專案 pull & push 方式
* git remote -v
* 查看現在使用方式
* git remote set-url origin git@github.com:USERNAME/OTHERREPOSITORY.git
* 修改成使用 SSH 的方式
* [範例網站](https://gist.github.com/fokayx/255b228ded2bca1c4f60)
## 使用紀錄
* git reset --hard (commit-hash)
* 強制回到該 (commit-hash) 的狀況,這次 merge 要退回而使用
* 可先用 git checkout (commit-hash) 查看是否是需要的紀錄資料
* git push -f (remote) (branch-name)
* 強制線上的紀錄同步
* 這次使用 git push -f 來強制讓線上的紀錄跟本地的紀錄同步(reset 回舊資料)
* 刪除本地分支
* 
* 刪除遠端(ex : github)分支
* 
* git reset head~
### 整理 commit
* git rebase -i HEAD~n
* 在要整理的分支合併 n 個commit
* master 練習的時候不能用,不確定問題是啥
* 好像是不能包含到最初的那個 commit
* 下完指令後 VScode 會跳出以下畫面
* 
* 不能從較早時間的 commit 開始 squash,詳細規則待練習
* 選擇好要 squash 那些 commit 後存檔關掉該頁面後會進入下一步,編輯整合後 commit 訊息
* 不需要的訊息可在前面加個 # 即可,修改完存檔關閉頁面後應可完成 rebase 整理 commit 的步驟
* [詳述整理 commit 的網站](http://puremonkey2010.blogspot.com/2019/10/git-git-merge-merge-squash-merge-rebase.html)
### 同步本地端 & 遠端的分支
* [刪除在遠端不存在的本地端分支](https://blog.csdn.net/qq_40140699/article/details/86494143)
* git branch -a
* 查看所有分支
* git remote show origin
* 查看本地端對應遠端的狀況
* git remote prune origin
* 刪除在遠端不存在的本地端分支
* [指令參考](https://www.techiedelight.com/zh-tw/delete-git-local-remote-branches/)
## 覺得之後會用上的參考
* [取回某次 Commit 的檔案版本](https://blog.darkthread.net/blog/get-file-from-git-commit/)
* [取得整理過後的 log 指令](https://stackoverflow.com/questions/1441010/the-shortest-possible-output-from-git-log-containing-author-and-date)
* git log --pretty=format:"%h%x09%an%x09%ad%x09%s"
* 
* %h = abbreviated commit hash
* %x09 = tab (character for code 9)
* %an = author name
* %ad = author date (format respects --date= option)
* %s = subject