How to retrieve committed code after switching back to the development branch when you committed code on a historical version using git checkout
0 条评论After using git checkout
to switch to a historical version, you forgot to
switch back to the development branch and committed a lot of code on the
historical version. Now, after switching back to the development branch, how can
you retrieve the code developed on the historical version?
- Find the historical version and use
git reflog
to view the commit ID. - Switch back to the historical version using
git checkout <commit_id>
. - Make a copy of the files.
- Switch back to the development branch.
- Overwrite the files in the project with the copied files.
- Commit the code to the development branch.
- 本文链接:https://xuehuayu.cn/article/964be38c.html
- 版权声明:① 标为原创的文章为博主原创,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接。② 标为转载的文章来自网络,已标明出处,侵删。