欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

git 刪除分支和回滾的實例詳解

 更新時間:2017年09月01日 09:41:54   投稿:lqh  
這篇文章主要介紹了git 刪除分支和回滾的實例詳解的相關(guān)資料,希望通過本文大家能理解掌握這部分內(nèi)容,需要的朋友可以參考下

git 刪除分支和回滾的實例詳解

【git 刪除本地分支】

git branch -D br

【git 刪除遠(yuǎn)程分支】

git push origin :br (origin 后面有空格)

git代碼庫回滾: 指的是將代碼庫某分支退回到以前的某個commit id

【本地代碼庫回滾】:

git reset --hard commit-id :回滾到commit-id,講commit-id之后提交的commit都去除

git reset --hard HEAD~3:將最近3次的提交回滾

【遠(yuǎn)程代碼庫回滾】:

這個是重點要說的內(nèi)容,過程比本地回滾要復(fù)雜

應(yīng)用場景:自動部署系統(tǒng)發(fā)布后發(fā)現(xiàn)問題,需要回滾到某一個commit,再重新發(fā)布

原理:先將本地分支退回到某個commit,刪除遠(yuǎn)程分支,再重新push本地分支

操作步驟:

1、git checkout the_branch

2、git pull

3、git branch the_branch_backup //備份一下這個分支當(dāng)前的情況

4、git reset --hard the_commit_id //把the_branch本地回滾到the_commit_id

5、git push origin :the_branch //刪除遠(yuǎn)程 the_branch

6、git push origin the_branch //用回滾后的本地分支重新建立遠(yuǎn)程分支

7、git push origin :the_branch_backup //如果前面都成功了,刪除這個備份分支 

【查看分支】

git branch -a

【創(chuàng)建本地分支并推送到遠(yuǎn)程】

git branch test

git push origin test

如有疑問請留言或者到本站社區(qū)交流討論,以上就是對git 回滾及刪除分支的詳解,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

最新評論