总有一天你会遇到下面的问题.

  1. 改完代码匆忙提交,上线发现有问题,怎么办? 赶紧回滚.
  2. 改完代码测试也没有问题,但是上线发现你的修改影响了之前运行正常的代码报错,必须回滚.

这些开发中很常见的问题,所以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

看似达到的效果是一样的,其实完全不同.

  1. 上面我们说的如果你已经push到线上代码库, reset 删除指定commit以后,你git push可能导致一大堆冲突.但是revert 并不会.
  2. 如果在日后现有分支和历史分支需要合并的时候,reset 恢复部分的代码依然会出现在历史分支里.但是revert 方向提交的commit 并不会出现在历史分支里.
  3. reset 是在正常的commit历史中,删除了指定的commit,这时 HEAD 是向后移动了,而 revert 是在正常的commit历史中再commit一次,只不过是反向提交,他的 HEAD 是一直向前的.
分类: Git

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

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://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

www.jcdqzdh.com · 2026-10-21 07:30

References:

No deposit payid pokies australia http://www.jcdqzdh.com/home.php?mod=space&uid=1085262

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://27vlz.ru · 2026-10-22 03:21

References:

MiFinity online pokies Australia real money https://27vlz.ru/user/harpcrib17/

https://pad.batsense.net/kWrkVJWQQnaVQtf-NMnidA · 2026-10-22 20:09

References:

Wire transfer casino reviews australia https://pad.batsense.net/kWrkVJWQQnaVQtf-NMnidA

https://www.1v34.com · 2026-10-23 00:32

References:

Real money wire transfer casinos australia https://www.1v34.com/space-uid-1847711.html

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

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

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

https://peatix.com · 2026-10-26 20:08

References:

Payid accepted pokies https://peatix.com/user/30787038/view

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

iwlnx.com · 2026-10-27 22:31

References:

Australian bank transfer casino http://iwlnx.com/forum/member.php?action=profile&uid=191344

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

http://downarchive.org/ · 2026-11-09 04:12

References:

Online pokies neosurf http://downarchive.org/user/monthgoal31/

发表回复

Avatar placeholder

您的邮箱地址不会被公开。 必填项已用 * 标注