?
對(duì)于已經(jīng)push或沒(méi)有push的,回退commit方式一致。只是最后push 的時(shí)候 ,如果修改了已經(jīng)push 的commit,那么需要使用git push -f
區(qū)別:git reset?commitID;? 回退到某個(gè)版本。中間的版本都會(huì)回退。
? ? ? ? ? ?git revert commitID; 只將commitID的代碼回退。中間的版本不變。且會(huì)形成一條commit 記錄。
// 方法一 回退到某個(gè)版本
git reset --hard commitID //不保留代碼,直接回退。
git push //直接推送
// 方法二 回退到某個(gè)版本
git reset --soft commitID //代碼回退到工作區(qū)
修改代碼
git add .
git commit -m 'xxx'
git push
// 方法三 只回退某個(gè)版本的修改
git revert commitID
git push
操作示例:
?
知識(shí)點(diǎn):文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-532902.html
* git revert HEAD 撤銷(xiāo)前一次 commit
* git revert HEAD^ 撤銷(xiāo)前前一次 commit
* git revert commit (比如:fa042ce57ebbe5bb9c8db709f719cec2c58ee7ff)撤銷(xiāo)指定的版本,撤銷(xiāo)也會(huì)作為一次提交進(jìn)行保存。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-532902.html
到了這里,關(guān)于git版本回退:revert回退其中一個(gè)提交/reset回退到某個(gè)版本的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!