Fast learning -Gti version rollback

7, version rollback

Objective: to retrieve mistakenly deleted code requires time, there is a function or an encapsulation system version V1, V3 version falls when the system does not function.

View Log (be sure to write in the time before each submitted comments on): Exit view the log press q

git log 					   #查看提交的历史
git log --pretty=oneline #查看提交的历史(格式化)

Rollback:

git reset --hard HEAD^         回退到上个版本
git reset --hard HEAD~3        回退到前3次提交之前,以此类推,回退到n次提交之前
git reset --hard commit_id     回退到指定版本

Procedure:
① create a temporary branch
② rollback temporary branch in
a rollback view the log determine the version of the above mentioned id.
B rollback.
③ need to copy the code to remove the temporary branch (there are questions asked Baidu)
$ git Branch -d need to be removed the branch name

Note:
A temporary branch just to retrieve the history file or code, throw-delete, there is no need to submit an interim branch line to the warehouse;.
B When you delete a temporary branch, you need to switch out the temporary branch (temporary exit branch. Make sure that no occupied) before you can delete;

Released 1939 original articles · won praise 2057 · Views 180,000 +

Guess you like

Origin blog.csdn.net/weixin_42528266/article/details/105142916