How to revert previous commit in git?
How to revert previous commit in git?
Here's how you can revert a previous commit in Git:
To revert a specific commit, you can use the git revert
command followed by the commit hash or reference (e.g., HEAD~1
for the previous commit). This will create a new commit that undoes the changes made in the specified commit.
git revert <commit-hash>
For example, to revert the previous commit:
git revert HEAD
This will open your default text editor, where you can edit the revert commit message if needed. Save and close the file to complete the revert process.
If you want to revert multiple commits, you can specify a range of commits using commit hashes or references. For example, to revert the last three commits:
git revert HEAD~2..HEAD
This will revert the changes made in the last three commits, creating a new commit for each reve...
middle
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào