2022-10-06
gitbook-reset-commit

git reset, 一直是我沒有弄懂的部分,這篇要多看幾次

  • 節錄文章中的說明
    • Reset 這個英文單字的翻譯是「重新設定」,但事實上 Git 的 Reset 指令用中文來說比較像是「前往」或「變成」,也就是「go to」或「become」的概念
    • $ git reset HEAD~2
      • 正確的說,上面這個指令應該要解讀成「我要前往兩個 Commit 之前的狀態」或是「我要變成兩個 Commit 之前的狀態」,而隨著使用不同的參數模式,原本的這些檔案就會丟去不同的區域。

Reference

Read More

2022-10-06
gitbook-view-log-of-a-file

滿好用的技巧,之前不知道,@@

  • 使用 sample
    • git log welcome.html
    • git log -p welcome.html

Reference

Read More

2022-10-06
gitbook-ignore

Read More

2022-10-05
gitbook-convenient-settings

設定

  • 有設定了 git log & git l,可以多用用看

Reference

Read More

2022-09-16
git-branch-tips

用 git 的好處,就是可以很方便的建立 & 刪除 branch
就記錄一下,目前有用到的 & 找到的使用 branch 的一些技巧 & 資料

使用 cmd 建立 local branch & 設定到 remote

  • 建立 local branch
    • git checkout -b <branch-name>
  • 將建立好的 branch push 到 remote
    • git push <remote-name> <branch-name>
      • <remote-name> is typically origin
  • 設定 push
    • git push --set-upstream <remote-name> <local-branch-name>
    • git push -u origin <local-branch-name>

清除 local branch 的方式 (單一的 branch)

  • 清 local branch 的方式
    • git branch -d <branch>

清除 remote branch 的方式 (一次 sync branch)

  • 跟 origin fetch 時,一併清除 remote 上不存在的 branch
    • $ git fetch --prune origin

清除 remote branch 的方式 (單一的 branch) - 不常用

  • 清 remote branch (已刪除的 branch)
    • $ git remote prune <remote>
    • `$ git remote -v

origin https://gitserver.com/user/repository.git (fetch)
origin https://gitserver.com/user/repository.git (fetch)
`

Reference

Read More

2022-06-27
git-two-user

公司改為使用 enterprises 的 github 服務,因而會發生和自己的 github account 發生衝突的情形,就找了一下解法囉

commit 到公司的 github 準備工作

  • ssh-add ~/.ssh/id_rsa

commit 到自己的 github 準備工作

  • ssh-add -d

Reference

Read More