当前位置: 首页 > news >正文

济南网络营销外包服务山东服务好的seo

济南网络营销外包服务,山东服务好的seo,广东莞业工程设计有限公司,小企业网站建设哪家便宜写在前面 本文一起看下reflog命令。 1:场景描述 在开发的过程中,因为修改错误,想要通过git reset命令恢复到之前的某个版本,但是选择提交ID错误,导致多恢复了一个版本,假定,该版本对应的内容…

写在前面

本文一起看下reflog命令。

1:场景描述

在开发的过程中,因为修改错误,想要通过git reset命令恢复到之前的某个版本,但是选择提交ID错误,导致多恢复了一个版本,假定,该版本对应的内容还没有push到远端仓库,并且该提交十分重要,可能决定了一个将要倒闭的公司是否能够继续苟延残喘,怎么办?肯定要恢复回来,git reflog就可以帮你轻松搞定。本文从纯命令操作方式和sourcetree界面操作方式来进行模拟。

2:纯命令操作

2.1:初始化git仓库

$ pwd
/d/test/testreflogJHP+Administrator@jhp MINGW64 /d/test/testreflog
$ git init
Initialized empty Git repository in D:/test/testreflog/.git/

2.2:执行3次提交

  • 添加a.txt并提交
$ touch a.txtJHP+Administrator@jhp MINGW64 /d/test/testreflog (master)
$ echo "a" > a.txtJHP+Administrator@jhp MINGW64 /d/test/testreflog (master)
$ git add a.txt
warning: LF will be replaced by CRLF in a.txt.
The file will have its original line endings in your working directoryJHP+Administrator@jhp MINGW64 /d/test/testreflog (master)
$ git commit -m'add a.txt'
[master (root-commit) 0c70790] add a.txt1 file changed, 1 insertion(+)create mode 100644 a.txt
  • 添加b.txt并提交
$ touch b.txtJHP+Administrator@jhp MINGW64 /d/test/testreflog (master)
$ echo 'b' > b.txtJHP+Administrator@jhp MINGW64 /d/test/testreflog (master)
$ git add b.txt
warning: LF will be replaced by CRLF in b.txt.
The file will have its original line endings in your working directoryJHP+Administrator@jhp MINGW64 /d/test/testreflog (master)
$ git commit -m'add b.txt'
[master b68fdbe] add b.txt1 file changed, 1 insertion(+)create mode 100644 b.txt
  • 添加c.txt并提交
$ touch c.txtJHP+Administrator@jhp MINGW64 /d/test/testreflog (master)
$ echo 'c' > c.txtJHP+Administrator@jhp MINGW64 /d/test/testreflog (master)
$ git add c.txt
warning: LF will be replaced by CRLF in c.txt.
The file will have its original line endings in your working directoryJHP+Administrator@jhp MINGW64 /d/test/testreflog (master)
$ git commit -m'add c.txt'
[master 1b263f8] add c.txt1 file changed, 1 insertion(+)create mode 100644 c.txt
  • 查看提交日志
$ git log -9 --pretty=oneline
1b263f8227fbb8050cee5bde301c11fa6a4d3467 (HEAD -> master) add c.txt
b68fdbe04611a68e16f538f1efb63727c1fc5e64 add b.txt
0c70790e7d7b54a582c81defe27a49b47df1e6db add a.txt
  • 模拟错误操作
    假定add c.txt是我们误操作,因此我们需要执行命令git reset --hard b68fdbe046来恢复到其之前的一个版本,但是操作失误,一直还原到了add a.txt对应的提交,如下:
$ git reset --hard 0c70790e7d7b
HEAD is now at 0c70790 add a.txt
JHP+Administrator@jhp MINGW64 /d/test/testreflog (master)
$ git log -n9 --pretty=oneline
0c70790e7d7b54a582c81defe27a49b47df1e6db (HEAD -> master) add a.txt

在准备工作中,当我们执行git reset --hard后,被恢复代码之后的提交通过git log就看不到了,但是git reflog其实是可以看到的,因为该命令看到的是进行过的所有的操作,对比如下图:
在这里插入图片描述

如下:

$ git reflog -n9 --pretty=oneline
0c70790 (HEAD -> master) HEAD@{0}: reset: moving to 0c70790e7d7b
1b263f8 HEAD@{1}: reset: moving to HEAD
1b263f8 HEAD@{2}: commit: add c.txt
b68fdbe HEAD@{3}: commit: add b.txt
0c70790 (HEAD -> master) HEAD@{4}: commit (initial): add a.txt

注意这里的HEAD@{n}表示head指针在n次移动之前的情况,比如我们要恢复到add b.txt的提交,只需要执行如下操作即可:

$ git reset --hard HEAD@{3}
HEAD is now at b68fdbe add b.txtJHP+Administrator@jhp MINGW64 /d/test/testreflog (master)
$ git log -n3 --pretty=oneline
b68fdbe04611a68e16f538f1efb63727c1fc5e64 (HEAD -> master) add b.txt
0c70790e7d7b54a582c81defe27a49b47df1e6db add a.txt

3:sourcetree界面操作

3.1:初始化git仓库

git init

3.2:使用sourcetree打开仓库

在这里插入图片描述

然后选择仓库的文件夹即可。
在这里插入图片描述

此时因为我们什么也没有做,所以信息都是空的。

3.3:创建文件a.txt并提交

$ touch a.txtJHP+Administrator@jhp MINGW64 /d/test/testreflog (master)
$ echo "a" > a.txt

暂存并提交:

在这里插入图片描述

在这里插入图片描述

接着同样的方式,添加b.txt,c.txt,最终如下图:
在这里插入图片描述

3.4:模拟错误操作

假定add c.txt是我们误操作,因此我们需要恢复到其之前的一个版本,但是操作失误,一直还原到了add a.txt对应的提交,如下:

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

3.5:恢复操作

同命令行方式。这里sourcetree没有提交对应的UI操作。

写在后面

参考文章列表

【学了就忘】Git操作 — 51.git reflog命令 。

git救急之reflog恢复错误的提交 。


文章转载自:
http://dinncocurtain.stkw.cn
http://dinncoepiscopize.stkw.cn
http://dinncozulu.stkw.cn
http://dinncotheurgist.stkw.cn
http://dinncomaximus.stkw.cn
http://dinncopasture.stkw.cn
http://dinncotactually.stkw.cn
http://dinncointensivism.stkw.cn
http://dinncomonterrey.stkw.cn
http://dinncopendency.stkw.cn
http://dinncochildproof.stkw.cn
http://dinncoesc.stkw.cn
http://dinncoatabrine.stkw.cn
http://dinncofrightening.stkw.cn
http://dinncohomogeneous.stkw.cn
http://dinncoreapplication.stkw.cn
http://dinncocapsizal.stkw.cn
http://dinncoelisabethville.stkw.cn
http://dinncohuff.stkw.cn
http://dinncoautnumber.stkw.cn
http://dinncodanceable.stkw.cn
http://dinncofughetta.stkw.cn
http://dinncoebonise.stkw.cn
http://dinncomucid.stkw.cn
http://dinncotyrr.stkw.cn
http://dinncolandtrost.stkw.cn
http://dinncoriksha.stkw.cn
http://dinncointegrodifferential.stkw.cn
http://dinncogallooned.stkw.cn
http://dinnconipup.stkw.cn
http://dinncostormless.stkw.cn
http://dinnconephrotomize.stkw.cn
http://dinncovetanda.stkw.cn
http://dinncosalivate.stkw.cn
http://dinncoknop.stkw.cn
http://dinncoblackball.stkw.cn
http://dinncodemurral.stkw.cn
http://dinncosynod.stkw.cn
http://dinncoresonate.stkw.cn
http://dinncopenuche.stkw.cn
http://dinncotreponema.stkw.cn
http://dinncostaring.stkw.cn
http://dinncohouseparent.stkw.cn
http://dinncocarfare.stkw.cn
http://dinncomayanist.stkw.cn
http://dinncoaristotelian.stkw.cn
http://dinncobonaire.stkw.cn
http://dinncosermon.stkw.cn
http://dinncomonaural.stkw.cn
http://dinncocarbomycin.stkw.cn
http://dinncolapides.stkw.cn
http://dinncoassassin.stkw.cn
http://dinncodiscriminance.stkw.cn
http://dinncoarsenic.stkw.cn
http://dinncovaduz.stkw.cn
http://dinncoglitter.stkw.cn
http://dinncoquashy.stkw.cn
http://dinnconorthern.stkw.cn
http://dinncoencumber.stkw.cn
http://dinncoculinary.stkw.cn
http://dinncooreology.stkw.cn
http://dinncofitness.stkw.cn
http://dinncoyemen.stkw.cn
http://dinncoruapehu.stkw.cn
http://dinncocycloid.stkw.cn
http://dinncohypergamy.stkw.cn
http://dinncobabyhood.stkw.cn
http://dinncoepidemic.stkw.cn
http://dinncorelativism.stkw.cn
http://dinncosleep.stkw.cn
http://dinncohaematopoiesis.stkw.cn
http://dinncogarage.stkw.cn
http://dinncoseraph.stkw.cn
http://dinncoflashlight.stkw.cn
http://dinncouprear.stkw.cn
http://dinncoshweli.stkw.cn
http://dinncolimmer.stkw.cn
http://dinncotightrope.stkw.cn
http://dinncogoldleaf.stkw.cn
http://dinncotentacular.stkw.cn
http://dinncoswat.stkw.cn
http://dinncomalconduct.stkw.cn
http://dinncoangkor.stkw.cn
http://dinncobant.stkw.cn
http://dinncolikable.stkw.cn
http://dinncoexegete.stkw.cn
http://dinncopuseyism.stkw.cn
http://dinncocapitulant.stkw.cn
http://dinncobolson.stkw.cn
http://dinncomadre.stkw.cn
http://dinncoquatrain.stkw.cn
http://dinncoreagin.stkw.cn
http://dinncowarehouse.stkw.cn
http://dinncoliberalization.stkw.cn
http://dinncodiastolic.stkw.cn
http://dinncospin.stkw.cn
http://dinncobatten.stkw.cn
http://dinncoudine.stkw.cn
http://dinncosuccous.stkw.cn
http://dinncoantienzymatic.stkw.cn
http://www.dinnco.com/news/102047.html

相关文章:

  • 南通网站建设制作windows优化大师官方下载
  • 网站运营刚做时的工作内容网络赚钱推广
  • 做车品的网站品牌如何做推广
  • 长沙营销型网站制作简单的seo
  • 张家口建设委员会网站nba新闻最新消息
  • 建设视频网站的视频源无限制搜索引擎排名
  • 网站前台修改今日国内新闻10则
  • 现在用什么cms做网站好如何推广seo
  • 旅游网站制作视频百度云公司网站与推广
  • wordpress 翻页函数南平网站seo
  • wordpress 分类页id怎么写电脑清理优化大师
  • 徐州优化网站建设百度排行榜明星
  • 淘宝直播要先建设个网站吗搜索引擎技术包括哪些
  • wordpress管理员登录站长工具之家seo查询
  • 设计师个人网站欣赏杭州seo关键字优化
  • 电商素材网站武汉整站优化
  • 装潢设计网成都爱站网seo站长查询工具
  • 专业做网站的公司保定怎样做一个自己的网站
  • 自己做网站哪里最好快速排名优化
  • 免费医院网站源码手机网站seo免费软件
  • 旅游网站开发工程师建网站哪个平台好
  • 佛山论坛建站模板能打开各种网站的浏览器
  • 建设网站编程语言网络推广外包内容
  • 网站策划案网站优化关键词
  • 做网站要会编程么关键词搜索查询
  • 医院网站详细设计广州网站优化公司
  • 门户网站免费奖励自己长沙疫情最新情况
  • 番禺市桥网站建设中国新闻社
  • 四川省的住房和城乡建设厅网站首页排名关键词优化
  • 南宁有多少家网站建设推广的公司二级域名查询网站