怎么將一個倉庫剛剛提交更新的代碼合并到另外一個瘋子役耕,之前一直沒有嘗試過翩瓜,這次在項目上深有體會来农。
運用場景:當需要將當前開發(fā)的代碼從一個分支合并到另外一個分支税灌,且只是將這一次的提交合并過去。
具體實現步驟:當前分支:develop
git add .
git commit -m 'feat:代碼說明'
git stash
:備份當前工作區(qū)的內容螟凭,保存到git 棧中虚青,從最近的一次commit中讀取相關內容
git checkout master
:切換到master分支
git checkout -b develop_message
:新建一個develop_message分支
git stash pop
:從git棧中獲取到最近一次stash進去的內容,恢復工作區(qū)的內容螺男。獲取之后棒厘,會刪除棧中對應的stash。由于可能會stash多次下隧,git使用棧管理奢人,我們可以使用git stash list查看所有的stash。
git add . git commit -m 'feat:代碼說明'
:在當前分支暫存代碼
git push
:推到遠程develop_message分支
git checkout develop
:切換到develop分支
git merge develop_message
;合并develop_message的代碼
git add . git commit -m 'feat:代碼說明'
:在當前分支暫存代碼
git push
:推到遠程develop分支