代碼寫到一半,想把當(dāng)前的代碼提交到另外一個新分支
1.創(chuàng)建新分支
git branch otherbranch
2.把當(dāng)前工作區(qū)恢復(fù)到上次提交的內(nèi)容,同時備份本地所做的修改
git stash
3.切換分支
git checkout otherbranch
4.獲取最近一次stash的修改內(nèi)容,之后刪除棧對應(yīng)的stash
git stash pop
5.添加前面修改的內(nèi)容
git add .
6.提交本地緩存
git commit -m "提交新修改"
7.推送新分支到遠程地址
git push origin otherbranch