為什麼會有這需求呢,因為特麼需求變動了好幾次。。。
1. 現狀
當前有三個Repo:
A: workspace/A/.git
B: workspace/B/.git
C: workspace/C/.git
由於只有我一個人開發,並且工程並不複雜,因此所有的Repo都只有一個分支【唯一的優點】。
目標是希望搞成下面這樣,且不丟失log:
workspace/Total/.git
workspace/Total/A
workspace/Total/B
workspace/Total/C
2. 過程
2.1
cd workspace
mkdir Total
cd Total
git init
2.2
mkdir A
git pull workspace/A
# 然後手動把所有A的檔案cp到A檔案裡
git add -A
git commit -m `merge A`
2.3
mkdir B
git fetch workspace/B
git merge FETCH_HEAD
# 然後手動把所有B的檔案cp到B檔案裡
git add -A
git commit -m `merge B`
2.4
mkdir C
git fetch workspace/C
git merge FETCH_HEAD
# 然後手動把所有C的檔案cp到C檔案裡
git add -A
git commit -m `merge C`
Tips
pull == fetch + merge