总有一天你会遇到下面的问题.
- 改完代码匆忙提交,上线发现有问题,怎么办? 赶紧回滚.
- 改完代码测试也没有问题,但是上线发现你的修改影响了之前运行正常的代码报错,必须回滚.
这些开发中很常见的问题,所以git的取消提交,回退甚至返回上一版本都是特别重要的.
大致分为下面2种情况:
1.没有push
这种情况发生在你的本地代码仓库,可能你add ,commit 以后发现代码有点问题,准备取消提交,用到下面命令
$ git reset [--soft | --mixed | --hard]
上面常见三种类型
- –mixed
会保留源码,只是将git commit和index 信息回退到了某个版本.
$ git reset #默认是 --mixed 模式 $ git reset --mixed #等价于 git reset
- –soft
保留源码,只回退到commit 信息到某个版本.不涉及index的回退,如果还需要提交,直接commit即可.
- –hard
源码也会回退到某个版本,commit和index 都回回退到某个版本.(注意,这种方式是改变本地代码仓库源码)
当然有人在push代码以后,也使用 reset --hard 回退代码到某个版本之前,但是这样会有一个问题,你线上的代码没有变,线上commit,index都没有变,当你把本地代码修改完提交的时候你会发现权是冲突…..
所以,这种情况你要使用下面的方式
2.已经push
对于已经把代码push到线上仓库,你回退本地代码其实也想同时回退线上代码,回滚到某个指定的版本,线上,线下代码保持一致.你要用到下面的命令
$ git revert
- git revert用于反转提交,执行evert命令时要求工作树必须是干净的.
- git revert用一个新提交来消除一个历史提交所做的任何修改.
revert 之后你的本地代码会回滚到指定的历史版本,这时你再 git push 既可以把线上的代码更新.(这里不会像reset造成冲突的问题)
revert 使用,需要先找到你想回滚版本唯一的commit标识代码,可以用 git log 或者web环境历史提交记录里查看.
$ git revert c011eb3c20ba6fb38cc94fe5a8dda366a3990c61 #通常,前几位即可 $ git revert c011eb3
git revert是用一次新的commit来回滚之前的commit,git reset是直接删除指定的commit
看似达到的效果是一样的,其实完全不同.
- 上面我们说的如果你已经push到线上代码库, reset 删除指定commit以后,你git push可能导致一大堆冲突.但是revert 并不会.
- 如果在日后现有分支和历史分支需要合并的时候,reset 恢复部分的代码依然会出现在历史分支里.但是revert 方向提交的commit 并不会出现在历史分支里.
- reset 是在正常的commit历史中,删除了指定的commit,这时 HEAD 是向后移动了,而 revert 是在正常的commit历史中再commit一次,只不过是反向提交,他的 HEAD 是一直向前的.
93 条评论
bd3333bat · 2026-07-26 00:26
The bonuses here are actually usable and not just for show. I managed to hit a nice win on my first try. Highly impressed with bd3333bat
juanbingophapk · 2026-07-26 00:26
The app version is just brilliant. I can play my favorite games on the go without any glitches. If you are in PH, you need to try juanbingophapk
livesport888 · 2026-07-26 00:27
Best place for live sports betting. The updates are instant and the betting options are huge. I always use livesport888 for my weekend matches
n52game · 2026-08-17 18:31
Scoured several review sites before making the switch and this place kept showing up as a top pick. The game variety is impressive and cashouts are processed without unnecessary delays. n52game
pgkinglogin · 2026-08-17 18:31
I stick to this site because the game updates are consistent and the jackpots actually pay out on schedule. The VIP program feels rewarding without being too aggressive. Head over to pgkinglogin and see what I mean
ecmarsbahis · 2026-08-17 18:31
I have been betting on live sports for years and this site finally matches the speed I expect from a modern platform. The match tracker updates in real time and the cashout options give me control right when the game shifts. Payments are processed without any hidden fees which keeps my bankroll healthy. A trustworthy home for fans who want seamless action and genuine value. ecmarsbahis
mwc · 2026-09-26 12:27
[8009]mwc লগইন ও অ্যাপ ডাউনলোড | অনলাইন স্লট গেম সাইট,mwc লগইন করে সেরা অনলাইন স্লট গেম সাইটের অভিজ্ঞতা নিন। বিকাশ দিয়ে ক্যাসিনো ডিপোজিট এবং লাইভ ক্যাসিনো খেলার নিয়ম জানতে আজই অ্যাপ ডাউনলোড করুন। visit: mwc
web site · 2026-09-28 19:47
Monster cock blow job picsVintage trucks for sale coeExcotic sexFree online male gay sexBook breast feeding
searsKayla synz porn trailorsScreaming cock fuckedSexy new year greeting cardDaughter porn vids daddyNew
vintage festival xnxx 88 – 90 ford escort gtPorn shitting siteOrgy
candyass vinylFree naked girl amatuer pics siteInstructor fucks profSunny
leone forst hardcoreVery young girl models eroticaRussian date sexyFree british porn girlsFree ruby knox porn pictures https://amp.xnxxtubexxx.cc/ Adult entertainment store
locatorsGwenth nudeMom catches daughter fucking boy friendCheerleaders naked in showerHigh boots
sex100 lesbo muffVaginal internal camsNude spring summer clothesPussy galore bond
costumeFacial cum shot videos xnxx Breast
enhancer siliconThumb experiment scientific methodFuck
the world movieGuild vintage western leather jacketBest free porn downloadSophie dee
ass masterpieceItalian porn star gallery
gamephlogin · 2026-10-05 21:12
Hey guys! Just wanted to share my experience with gamephlogin. Super easy to use, and the login process is a breeze. Definitely recommend checking it out! gamephlogin
https://gaiaathome.eu · 2026-10-16 23:41
References:
Legal wire transfer casinos australia https://gaiaathome.eu
https://truckwiki.site · 2026-10-17 07:56
References:
Online casinos Osko https://truckwiki.site
instant withdrawal pay id pokies · 2026-10-17 09:03
References:
Top rated payid pokies instant withdrawal pay id pokies
pay id pokies australia · 2026-10-17 10:10
References:
Pokies payid instant pay id pokies australia
https://doc.anagora.org/F1VstoxVR3WqhAOsqh42rw · 2026-10-17 12:40
References:
No verification payid pokies australia https://doc.anagora.org/F1VstoxVR3WqhAOsqh42rw
https://www.forum.uookle.com · 2026-10-17 16:05
References:
Best payid pokies australia https://www.forum.uookle.com
free spins payid pokies australia · 2026-10-17 18:32
References:
Australian payid pokies free spins payid pokies australia
https://xtuml.org · 2026-10-17 18:37
References:
Osko casino real money Australia https://xtuml.org
dreevoo.com · 2026-10-17 19:13
References:
Low deposit payid pokies dreevoo.com
https://sonnik.nalench.com/user/pimpleuncle2/ · 2026-10-17 20:17
References:
Best online pokies neosurf australia https://sonnik.nalench.com/user/pimpleuncle2/
write.frame.gargantext.org · 2026-10-18 01:03
References:
How to play pokies with payid write.frame.gargantext.org
mobile casino payid · 2026-10-18 03:41
References:
Payid casino no deposit bonus mobile casino payid
boardgameswiki.site · 2026-10-18 04:09
References:
Bpay accepted pokies boardgameswiki.site
https://telegra.ph · 2026-10-18 06:29
References:
Fast bpay deposit pokies https://telegra.ph
md.interhacker.space · 2026-10-18 06:50
References:
BPay pokies instant play md.interhacker.space
blackjack online MiFinity Australia · 2026-10-18 16:44
References:
Deposit match MiFinity casino AU blackjack online MiFinity Australia
https://shareshortcuts.com/u/dancersuit0 · 2026-10-18 18:07
References:
Is MiFinity safe for online casinos https://shareshortcuts.com/u/dancersuit0
online gambling sites that accept credit cards australia · 2026-10-18 19:45
References:
Online casinos that accept amex australia online gambling sites that accept credit cards australia
MiFinity casino VIP program Australia · 2026-10-18 21:41
References:
Real money casino Australia MiFinity MiFinity casino VIP program Australia
https://philosophywiki.space/ · 2026-10-19 00:39
References:
Neosurf accepted casinos https://philosophywiki.space/
https://codimd.syssec.org/ · 2026-10-19 06:41
References:
Top australian online casinos accepting neosurf https://codimd.syssec.org/
https://skyscrapperwiki.site/wiki/Neosurf_Casinos_in_Australia_2026_Full_List_Guide · 2026-10-19 07:20
References:
New neosurf online casinos aus https://skyscrapperwiki.site/wiki/Neosurf_Casinos_in_Australia_2026_Full_List_Guide
https://mapleprimes.com/ · 2026-10-19 16:45
References:
Online casinos accepting bank wire australia https://mapleprimes.com/
nlvbang.com · 2026-10-19 17:50
References:
Direct bank transfer pokies australia nlvbang.com
https://www.88m2.com · 2026-10-19 22:04
References:
Australian casinos accepting wire transfers https://www.88m2.com
otto-holt-3.hubstack.net · 2026-10-19 23:40
References:
Osko pokies online australia otto-holt-3.hubstack.net
instant withdrawal casino Osko · 2026-10-20 00:10
References:
Osko casino $5 deposit instant withdrawal casino Osko
play56.net · 2026-10-20 07:46
References:
Wire transfer live casino australia play56.net
pokies with payid deposit · 2026-10-20 08:53
References:
How to play pokies with payid pokies with payid deposit
1 dollar payid pokies · 2026-10-20 13:23
References:
Real money payid online pokies 1 dollar payid pokies
Osko instant withdrawal casinos · 2026-10-20 13:29
References:
Fast withdrawal osko payid pokies Osko instant withdrawal casinos
wire transfer casino sign up australia · 2026-10-20 15:09
References:
Bank transfer casinos australia wire transfer casino sign up australia
https://www.forum.uookle.com/ · 2026-10-20 19:20
References:
Play online pokies payid australia https://www.forum.uookle.com/
http://bbs.sdhuifa.com · 2026-10-20 22:58
References:
Real money wire transfer casinos australia http://bbs.sdhuifa.com
pad.stuve.de · 2026-10-21 01:50
References:
Osko instant withdrawal casinos https://pad.stuve.de/w1gFFxo8SVKOU_UhrXt6Rg
adair-oneill.hubstack.net · 2026-10-21 01:57
References:
Online pokies payid australia https://adair-oneill.hubstack.net/best-payid-casinos-in-australia-withdrawal-and-deposits-with-payid-1792427581
http://maskarad.bomba-piter.ru/user/lilysandra9/ · 2026-10-21 07:24
References:
New bpay pokie sites australia http://maskarad.bomba-piter.ru/user/lilysandra9/
www.jcdqzdh.com · 2026-10-21 07:30
References:
No deposit payid pokies australia http://www.jcdqzdh.com/home.php?mod=space&uid=1085262
forum.drapinballleague.com · 2026-10-21 08:02
References:
How to play pokies with payid https://forum.drapinballleague.com/member.php?action=profile&uid=155845
https://gamingwiki.space · 2026-10-21 08:35
References:
Safe BPay pokies https://gamingwiki.space/wiki/Best_Fast_Payout_Casinos_Online_Top_Instant_Withdrawal_Sites
http://www.automingwei.com · 2026-10-21 14:53
References:
Is BPay safe for online pokies http://www.automingwei.com/home.php?mod=space&uid=587028
https://www.forum.uookle.com/ · 2026-10-22 00:39
References:
Live casino Australia MiFinity https://www.forum.uookle.com/home.php?mod=space&uid=1846105
https://27vlz.ru · 2026-10-22 03:21
References:
MiFinity online pokies Australia real money https://27vlz.ru/user/harpcrib17/
MiFinity casino roulette Australia · 2026-10-22 05:39
References:
Fast withdrawal MiFinity casinos https://literaturewiki.site/wiki/Best_3D_Pokies_Australia_2026_Play_Free_3D_Online_Slots
https://codimd.camba.coop/azMKYfFZQ1q-24w_jpYXfg · 2026-10-22 09:27
References:
Neosurf payout casinos australia https://codimd.camba.coop/azMKYfFZQ1q-24w_jpYXfg
https://steenberg-foley-2.thoughtlanes.net/we-tested-neosurf-at-online-casinos-our-honest-2026-review-1792594987 · 2026-10-22 11:39
References:
Neosurf jackpot pokies australia https://steenberg-foley-2.thoughtlanes.net/we-tested-neosurf-at-online-casinos-our-honest-2026-review-1792594987
neosurf online pokies australia real money · 2026-10-22 14:48
References:
Neosurf casino free spins australia https://literaturewiki.site/wiki/Online_Casino_Neosurf_App_Play_Slots_Live_Casino
https://pad.batsense.net/kWrkVJWQQnaVQtf-NMnidA · 2026-10-22 20:09
References:
Wire transfer casino reviews australia https://pad.batsense.net/kWrkVJWQQnaVQtf-NMnidA
bank wire casino deposits · 2026-10-22 22:15
References:
Online casino banking options australia https://campbell-green-2.hubstack.net/best-payout-online-casinos-in-australia-2026-highest-payouts-1792619771
https://www.1v34.com · 2026-10-23 00:32
References:
Real money wire transfer casinos australia https://www.1v34.com/space-uid-1847711.html
gambling sites that accept Osko · 2026-10-23 06:20
References:
Osko live casino https://xn—-7sbarohhk4a0dxb3c.xn--p1ai/user/combtaiwan97/
https://www.88m2.com · 2026-10-23 07:43
References:
Osko fast payout pokies https://www.88m2.com/?364393
bank transfer casino real money Australia · 2026-10-23 09:25
References:
Wire transfer jackpot casino australia http://www.qingdaomop.com/?299437
osko fast payout casinos · 2026-10-23 14:03
References:
Osko casinos for Australians http://bbs.88moli.top/home.php?mod=space&uid=213805
https://app.wedonthavetime.org/profile/yewinsect92 · 2026-10-23 14:58
References:
Casino direct bank deposit australia https://app.wedonthavetime.org/profile/yewinsect92
Osko pokies minimum deposit · 2026-10-23 15:19
References:
Osko pokies payment option https://dok.kompot.si/Qvz5dy2qR5O3Yp79zPbPBQ
https://prpack.ru/user/fingerclutch60/ · 2026-10-23 15:32
References:
Electronic funds transfer casino australia https://prpack.ru/user/fingerclutch60/
xhdyz.cn · 2026-10-23 19:31
References:
Osko casino banking Australia http://xhdyz.cn/home.php?mod=space&uid=1240421
http://sglpw.cn/home.php?mod=space&uid=760981 · 2026-10-23 19:41
References:
Low deposit osko pokies http://sglpw.cn/home.php?mod=space&uid=760981
https://www.rcfl.com.hk · 2026-10-24 00:01
References:
Legit osko casinos https://www.rcfl.com.hk/home.php?mod=space&uid=10365121
https://text.dsf.hs-heilbronn.de/0jMUevUtTYiGDgr2iODMPQ · 2026-10-24 01:32
References:
10 dollar deposit pokies payid https://text.dsf.hs-heilbronn.de/0jMUevUtTYiGDgr2iODMPQ
wargame-workshop.com · 2026-10-24 02:03
References:
Payid pokies welcome bonus http://wargame-workshop.com/bbs/home.php?mod=space&uid=1549031
payid pokies australia · 2026-10-25 23:07
References:
High roller payid pokies https://topsitenet.com/profile/grouppajama25/2682798/
https://prpack.ru/user/gamewren99/ · 2026-10-25 23:32
References:
Pokies payid accepted australia https://prpack.ru/user/gamewren99/
low deposit payid pokies · 2026-10-26 07:47
References:
Highest paying payid pokies australia https://codimd.syssec.org/SnOsTVB7StKa_Ph49LpEmA
pay id pokies australia · 2026-10-26 08:00
References:
Direct bank transfer payid pokies http://bbs.wj10001.com/home.php?mod=space&uid=3274551
https://www.notizen.kita.bayern · 2026-10-26 17:19
References:
Payid withdrawal online pokies https://www.notizen.kita.bayern/ZjNzpuz5R7WJ7aK6anCMJQ
hedgedoc.ludos-disciplinarum-misi.fyi · 2026-10-26 18:32
References:
Play online pokies payid australia https://hedgedoc.ludos-disciplinarum-misi.fyi/-ZAAxO5hQjiWMZV5_5G8_g
https://peatix.com · 2026-10-26 20:08
References:
Payid accepted pokies https://peatix.com/user/30787038/view
https://pad.koeln.ccc.de/ · 2026-10-26 21:35
References:
Payid pokies reviews https://pad.koeln.ccc.de/_CBEKTqhQrqm_Dkhg7AI4Q
http://www.lezcc.com/ · 2026-10-26 22:17
References:
BPay deposit pokies http://www.lezcc.com/?697243
best Australian casinos accepting MiFinity · 2026-10-27 02:55
References:
Real cash MiFinity casino Australia https://ardsglobal.org/author/periodinsect03/
http://bbs.88moli.top/ · 2026-10-27 03:36
References:
Bpay pokie apps real money http://bbs.88moli.top/home.php?mod=space&uid=227140
neosurf casino free chip australia · 2026-10-27 11:59
References:
Minimum neosurf deposit casino aus https://hedgedoc.ludos-disciplinarum-misi.fyi/ClE0C_ZrQlClPOz33o-CRw
10 dollar neosurf casino australia · 2026-10-27 13:18
References:
Best neosurf casino bonus aus https://hedgedoc.ludos-disciplinarum-misi.fyi/P25lJSA3QjimMyxX-SQaCA
iwlnx.com · 2026-10-27 22:31
References:
Australian bank transfer casino http://iwlnx.com/forum/member.php?action=profile&uid=191344
https://gardenwiki.site/wiki/Instant_Withdrawal_Casinos_Australia_2026_Fast_Payout_Casinos · 2026-10-28 18:29
References:
Osko pokies online australia https://gardenwiki.site/wiki/Instant_Withdrawal_Casinos_Australia_2026_Fast_Payout_Casinos
http://wudao28.com/home.php?mod=space&uid=3049717 · 2026-10-30 12:54
References:
Direct bank transfer casinos australia http://wudao28.com/home.php?mod=space&uid=3049717
$10 deposit bonus casino neosurf australia · 2026-10-30 13:12
References:
$1 minimum deposit casino neosurf australia https://comsenz-service.com/?271160
https://gardenwiki.site/ · 2026-11-08 02:27
References:
Muchbetter accepted casinos https://gardenwiki.site/wiki/MuchBetter_Casino_Canada_Mobile_EWallet_Guide
https://www.youtube.com · 2026-11-09 00:20
References:
Online casino canada that accepts idebit https://www.youtube.com/redirect?q=https://adda.org/media/pgs/idebit-casinos-canada-fees-and-cashouts.html
http://downarchive.org/ · 2026-11-09 04:12
References:
Online pokies neosurf http://downarchive.org/user/monthgoal31/
https://hedgedoc.ludos-disciplinarum-misi.fyi/zRyPp0AOTK-X3MwbRSGWnA · 2026-11-09 22:11
References:
Fastest payout neosurf casinos https://hedgedoc.ludos-disciplinarum-misi.fyi/zRyPp0AOTK-X3MwbRSGWnA
neosurf pokies real money · 2026-11-09 22:46
References:
Neosurf casino app https://bookmarkdaily.site/item/buy-neosurf-australia-online-official-partner