openpilot備份fork的branch版本

常常跳到不同的openpilot fork,如sunnypilot、forgpilot等等

但有時候更新後版本未必穩定,甚至功能被拿掉,因此在更新的同時備份branch到自己的github才方便後續降版本使用

以sunnypilot的dev-c3為例:

# 進入桌面
cd ~/Desktop/

# 建立github資料夾並進入
mkdir -p github && cd github

# Clone自己的openpilot倉庫到本地
git clone git@github.com:nomo9133/openpilot.git

# 進入openpilot資料夾
cd openpilot

# 添加sunnypilot的遠端倉庫
git remote add upstream git@github.com:sunnypilot/sunnypilot.git

# 確認是否成功添加遠端倉庫
git remote -v
# 預期會看到以下兩個遠端倉庫:
# origin    git@github.com:nomo9133/openpilot.git (fetch)
# origin    git@github.com:nomo9133/openpilot.git (push)
# upstream  git@github.com:sunnypilot/sunnypilot.git (fetch)
# upstream  git@github.com:sunnypilot/sunnypilot.git (push)

# 切換到dev-c3 branch
git checkout dev-c3

# 為了避免覆蓋,將當前的dev-c3 branch改名為包含日期的版本
git branch -m dev-c3 dev-c3-20241116

# 將改名後的分支推送到遠端倉庫,備份舊版本
git push origin dev-c3-20241116

# 創建一個新的dev-c3 branch,作為即將更新的分支
git checkout -b dev-c3

# 從上游倉庫(upstream)拉取最新的dev-c3分支
git fetch upstream dev-c3

# 硬重置當前分支到upstream的最新dev-c3狀態
git reset --hard upstream/dev-c3

# 強制推送新拉下來的dev-c3分支到自己的倉庫
git push origin dev-c3 -f

# 確認當前本地的branch列表,應該可以看到兩個分支:
# * dev-c3
#   dev-c3-20241116
git branch

Visited 18 times, 1 visit(s) today

已發佈

分類:

, ,

作者:

留言

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *