顯示具有 git 標籤的文章。 顯示所有文章
顯示具有 git 標籤的文章。 顯示所有文章

2020-01-17

[GIT] Remove Submodule


  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule

# Remove the submodule entry from .git/config
git submodule deinit -f path/to/submodule

# Remove the submodule directory from the superproject's .git/modules directory
rm -rf .git/modules/path/to/submodule

# Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule
git rm -f path/to/submodule

2017-10-26

[GIT] How to merge multi-commits to one commit

在開發過程中, 會不斷 commit 已經寫好的 code 到 local git.  最近在 refactor 其他人寫的code, 先將原先的code comment, 修改測試後就直接commit , 忘記將 comment 清理掉. 會變成多好幾個 commint.

所以, 找尋怎樣可以將多個 commit 合併成一個 commit.  從網路上看到許多教學, 歸納一下做法.
1. 使用 rebase 到要合併的 commit Log 的前一個
2. 使用 pick and squash 合併.

因為使用 source tree, 記錄一下做法. 下面假設有四個commit
A -> B1-> B2-> B3 , B3 是最後一個 commit.  希望將 B1, B2, B3 變成 B

1. 點選 A , 按下滑鼠右鍵.
2. 選擇 "Rebase Children of A Interactively"
3.  在畫面中, 點選 B2, 後按下 "squash with previous".  B1, B2 變成一條
4.  在畫面中, 點選 B3, 後按下 "squash with previous".  B1, B2, B3 整合變成一條
5. 按下 "Edit Message" 修改 commit message
6. 最後按下 "OK", 即讓 commit 變成  A-> B

參考資料

1. 使用git squash 合併commit
2. 如何合併多個commits

2013-08-16

[Mac] 新增Git Console

安裝與設定步驟如下

1.Install git-osx-installer .
2. edit PATH
sudo vi /etc/paths
add /usr/local/git/bin to Last Line