美文网首页GitGit使用
git单文件版本恢复

git单文件版本恢复

作者: EldonZhao | 来源:发表于2017-02-09 11:33 被阅读76次
    • 确认需要恢复的版本号:
    待恢复版本号
    • 恢复文件到对应版本:
    eldon@ubuntu:~/github/ColusLifeDemo/Browser$ git reset fc7237c8c0e13f20b0be97a57ed2b707e54532c3 app/index.html
    Unstaged changes after reset:
    M   Browser/app/index.html
    
    • 确认恢复内容:
    eldon@ubuntu:~/github/ColusLifeDemo/Browser$ git reset 90b911c98a67237cd9c31ecee74c3bea2dca9767 app/index.html
    Unstaged changes after reset:
    M   Browser/app/index.html
    eldon@ubuntu:~/github/ColusLifeDemo/Browser$ git checkout app/index.html
    eldon@ubuntu:~/github/ColusLifeDemo/Browser$ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)
        modified:   app/index.html
    eldon@ubuntu:~/github/ColusLifeDemo/Browser$ git diff app/index.html
    
    • 提交代码:
    eldon@ubuntu:~/github/ColusLifeDemo/Browser$ git commit -a
    [master 71abf0e] Solve missing amap problem
     1 file changed, 4 insertions(+)
    eldon@ubuntu:~/github/ColusLifeDemo/Browser$ git push
    

    相关文章

      网友评论

        本文标题:git单文件版本恢复

        本文链接:https://www.haomeiwen.com/subject/tadiittx.html