昨天,实习时将远程仓库的master搞乱了后,尝试去回退版本。
打开“黑匣子”,查看原因
1.下午的15:17,提交修订版本后,此时远程仓库的代码没有任何问题。
commit cd91d900ec3ad53427131558706d349deac95781 (origin/old, origin/branch2)
Author: Dennis
Date: Thu Aug 6 15:17:34 2020 +0800
fix: <87><8A><94><87><99>
2.下午17:47,我脑子进水了,新建一个one分支,这个分支是随便的一个项目,并在远程仓库提交申请后,成功合并。于是开始了一切挽救的措施。
commit 328b781a15eeca7f7b48167e9e7c71d72b685fee
Merge: cd91d90 f27e612
Author: Administrator
Date: Thu Aug 6 17:47:24 2020 +0800
Merge branch 'one' into 'master'
feat(something):request merge [one]
See merge request cnpc/addresslist!1
3.下午18:44使用idea的版本回退,成功回退到就版本,申请merge,这才解决问题。
在版本回退的时候,务必注意。在分支上进行回退,然后提交到远程仓库。再开启一个项目从远程仓库下载下来。可以进行测试,也可以和自己备份的项目进行回退,因为本地的还没有被破坏。方可成功回退。令注意选择回退的版本的三种类型。
–soft
Does not touch the index file or the working tree at all (but resets the head to
, just like all modes do). This leaves all your changed files “Changes to be committed”, as git status
would put it.
–mixed
Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action.
If -N
is specified, removed paths are marked as intent-to-add (see [git-add1]).
–hard
Resets the index and working tree. Any changes to tracked files in the working tree since
are discarded.
工作区 暂存区都会被回退。
这个命令来源于廖雪峰老师的博客,目的是添加远程库。从这句话也能看出master是远程仓库的名字,所以我也可以叫小王,小李,小张。
git remote add origin [email protected]:michaelliao/learngit.git
gitlab似乎在权限不足的情况下不能从自己的master提交到远程master,需要经过创建分支,再从分支上申请远程合并。查了很多这方面的东西,没有得到很清楚的答案,在此记录一下。