Skip to content

Instantly share code, notes, and snippets.

@b2977053
Created March 19, 2020 07:52
Show Gist options
  • Save b2977053/d37d113125ba40c284e2791b056bcab2 to your computer and use it in GitHub Desktop.
Save b2977053/d37d113125ba40c284e2791b056bcab2 to your computer and use it in GitHub Desktop.
cherry-pick
挑選 <SHA1> 合併到本分支
# 建立資料夾 與 版本庫
mkdir git-cherry-pick-demo
cd git-cherry-pick-demo
git init
# 新增檔案 a.txt 並提交。
echo 'a.txt first commit' > a.txt
git add .
git commit -m 'a.txt first commit'
# 新增檔案 b.txt 並提交。
echo 'b.txt first commit' > b.txt
git add .
git commit -m 'b.txt first commit'
# 新增檔案 C.txt 並提交。
echo 'C.txt first commit' > C.txt
git add .
git commit -m 'C.txt first commit'
# 查看 LOG
git reflog
# 移到歷史特定版本
git checkout HEAD@{2}
# 建立分支
git checkout -b branch1
# 查看 LOG 與標籤
git log
git reflog
git show-ref
git log master
# 挑選 <SHA1> 合併到本分支
git cherry-pick <SHA1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment