Câu hỏi phỏng vấn Git
Câu hỏi

How to revert previous commit in git?

Câu trả lời

Here's how you can revert a previous commit in Git:

Reverting a Commit

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.

bash Copy
git revert <commit-hash>

For example, to revert the previous commit:

bash Copy
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.

Reverting Multiple Commits

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:

bash Copy
git revert HEAD~2..HEAD

This will revert the changes made in the last three commits, creating a new commit for each reve...

middle

middle

Gợi ý câu hỏi phỏng vấn

middle

Explain the advantages of Forking Workflow

senior

What is difference between git stash pop and git stash apply ?

junior

What is the difference between git pull and git fetch ?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào