【版本管理】git单文件版本恢复

  • 确认需要恢复的版本号:
【版本管理】git单文件版本恢复_第1张图片
待恢复版本号
  • 恢复文件到对应版本:
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 ..." 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单文件版本恢复)