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

entry

What is the command to write a commit message in Git?

expert

What are "git hooks"?

senior

What is the difference between git clone , git clone --bare and git clone --mirror ?

Bình luận

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

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