因為一些原因
想把某個 Git Repo 中的資料夾另外分出來
分出來之後又發現其中當初不該丟上去的東西
我又對 git 不熟Orz
就邊 Google 邊想辦法弄出來
在這做個紀錄
- 先 clone 下來。
git clone [Repo位址] - 切換目錄。
cd [目錄名稱] - rebase -i 到欲更改 commit 的 parent commit。
git rebase -i [欲更改commit的sha]^1 - 想改的改一改,想刪的刪一刪。
詳情參照參考資料中的教學。 - 更新檔案變動。
git add -A - 修改 commit。
git commit --amend - rebase 回去。
git rebase --continue - 把要留的資料夾切出來。
git filter-branch --prune-empty --subdirectory-filter [資料夾名稱] - 更改遠端 Repo 的位址。
git remote set-url origin [Repo位址] - Push,完成。
git push -u origin [BRANCH名]