git revert

datajcthemax·2023년 6월 13일
0

git/github

목록 보기
8/18

The git revert command is used to create a new commit that undoes the changes made in a previous commit. This command adds new history to the project (it doesn't modify existing history). This makes it a safe operation to use when you're collaborating with others, as it doesn't require force pushing.

Here's a basic example of how to use git revert:

git revert <commit>

Where <commit> is the commit hash that you want to undo. You can find this hash by using git log.

When you run this command, Git will create a new commit that undoes all of the changes that were made in the specified commit. Then, it will open your text editor and prompt you to enter a commit message for this new "revert commit". Once you save and close the editor, the revert commit will be added to the project history.

It's important to note that git revert can be used to undo the effects of many commits at once. For example, to revert the last three commits, you could use:

git revert HEAD~2..HEAD

This uses a commit range to specify the last three commits (remember, the range is inclusive of the first parameter, but exclusive of the second).

git revert is a powerful tool when you need to undo changes, but want to keep the history of your project intact.

0개의 댓글