In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use Git to recover to the previous submission". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "how to use Git to recover to the previous submission" together!
Sometimes you want to go back to your previous commit and keep all the previous changes. You want to commit new code between the previous commit and the current HEAD.
First, create a new branch called 'revert-branch' from the commit you want to return. In this example, we want to roll back to the previous commit (assuming the current branch is 'master') and make changes on this commit.
git branch revert-branch HEAD^
Next switch to the new branch:
git checkout revert-branch
Teach a trick: soft restore from master to HEAD of new branch. Soft restore will change the state of HEAD without affecting the tree.
git reset --soft master
Now, we execute git status and we will see the changes we want to restore to the commit. I'm going to undo adding 'second.txt', but it could also be a more complex change:
$ git status # On branch revert-branch # Changes to be committed: # (use to unstage) # # deleted: second.txt #
Now let's submit this 'reversal':
git commit -m "reverted to initial state. "Thank you for your reading. The above is the content of" How to use Git to recover to the previous submission ". After studying this article, I believe everyone has a deeper understanding of how to use Git to recover to the previous submission. The specific use situation still needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.