git 指令

remote 的 origin 上有 branch A,local 沒有 branch A。想建立一個跟 origin/A 進度相同的 local branch A

git switch -c A origin/A

遠端分枝名稱寫錯了,想改名字。先刪除 remote 的 origin 上的 A 分支,然後再用正確名字 push 一次

git push origin --delete A

參考:


把本地的 A 分枝 push 到遠端 origin 上的 B 分枝

git push origin A:B

複製其他分枝的 commit 到當前所在的分枝

git cherry-pick <commit hash code>  // 只複製一個 commit
git cherry-pick <commit hash code 1>..<commit hash code 2>  // 複製多個連續的 commit(不包含 hash code 1 的那個 commit)

參考:


暫存目前未 commit 的程式碼

git stash

取出暫存的程式碼

git stash pop

強制蓋掉 remote 的分枝(非常確定這個分支沒有其他人在 commit 時才用,以免把別人的 commit 蓋掉)

git push --force-with-lease

參考:


Comments

Popular posts from this blog

shop_platform - 建立多對多關聯:Association Object

[計算機概論] SR Flip-Flop