Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the differences between revert and reset of git

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the git revert and reset what the difference between the relevant knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe you read this git revert and reset what differences the article will have a harvest, let's take a look at it.

The difference between git revert and git reset

Git revert generates a new submission to undo a submission, and the commit before this submission will be retained.

When git reset is returned to a certain submission, both the submission and the previous commit will be retained, but the subsequent changes will be returned to the temporary storage area.

For a specific example, suppose there are three commit, git st:

Commit3: add test3.c

Commit2: add test2.c

Commit1: add test1.c

When git revert HEAD~1 is executed, commit2 is revoked

Git log can see:

Revert "commit2": this reverts commit 5fe21s2...

Commit3: add test3.c

Commit2: add test2.c

Commit1: add test1.c

There is no change in git status.

If you execute git reset-- soft (default) HEAD~1 instead, run git log

Commit2: add test2.c

Commit1: add test1.c

If you run git status, the test3.c is in the staging area, ready to commit.

If you execute git reset-- hard HEAD~ 1 instead,

Display: HEAD is now at commit2, run git log

Commit2: add test2.c

Commit1: add test1.c

Run git st without any change

In addition:

Git revert is to undo the commit as a new commit.

This is the end of the article on "what are the differences between revert and reset of git". Thank you for reading! I believe you all have a certain understanding of the knowledge of "what are the differences between revert and reset of git". If you want to learn more, you are welcome to follow the industry information channel.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report