Git 版本回退


轉載:https://www.liaoxuefeng.com/wiki/896043488029600/897013573512192

版本回退

修改redom.txt文件

版本1:wrote a readme file

Git is a version control system.
Git is free software.

版本2:add distributed

 

Git is a distributed version control system.
Git is free software.

 

版本3:append GPL

Git is a distributed version control system.
Git is free software distributed under the GPL.

查看提交歷史 $git log

$ git log
commit 2de5fcfb77abef77a3715a5837884e0839427630 (HEAD -> master)Author: dream <又又ITDream@163.com>
Date:   Thu May 9 15:33:06 2019 +0800

    append GPL

commit 72d336879f4dcd4761b949a167dd95d7e4863840
Author: dream <又又ITDream@163.com>
Date:   Thu May 9 15:31:02 2019 +0800

    distributed

commit 58748418efa662590dd7b71a60dc3c68d24adaa1
Author: dream <又又ITDream@163.com>
Date:   Thu May 9 14:58:52 2019 +0800

    worte a readme file

查看版本號:$git log --pretty== oneline

$ git log --pretty=oneline
2de5fcfb77abef77a3715a5837884e0839427630 (HEAD -> master) append GPL
72d336879f4dcd4761b949a167dd95d7e4863840 distributed
58748418efa662590dd7b71a60dc3c68d24adaa1 worte a readme file
2de5...是commit id(版本號,我們每個人的版本是不一樣的)  HEAD表示當前版本

回退版本:$git reset --hard HEAD^
$ git reset  --hard HEAD^
HEAD is now at 72d3368 distributed

查看版本內容:$cat 文件名稱

$ cat readme.txt
Git is a distributed version control system.
Git is free software.

指定回到未來某個版本:$git reset --hard 版本號(寫幾位即可)

$ git reset --hard 2de5f
HEAD is now at 2de5fcf append GPL

查看命令歷史:$ git reflog

 
        
$ git reflog
2de5fcf (HEAD -> master) HEAD@{0}: reset: moving to 2de5f
72d3368 HEAD@{1}: reset: moving to HEAD^
2de5fcf (HEAD -> master) HEAD@{2}: commit: append GPL
72d3368 HEAD@{3}: commit: distributed
5874841 HEAD@{4}: reset: moving to HEAD^
7911e59 HEAD@{5}: reset: moving to HEAD^
808c93e HEAD@{6}: reset: moving to HEAD^
9f92a21 HEAD@{7}: commit: append GPL
808c93e HEAD@{8}: commit: add distributed
7911e59 HEAD@{9}: commit: add 3 files
5874841 HEAD@{10}: commit (initial): worte a readme file
 
        

 

 
        

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM