What is rollback in git ?
source link: https://www.frontendinterviewquestions.com/interview-questions/what-is-rollback-in-git
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
What is rollback in git ?
In Git, a rollback typically refers to the act of reverting a repository or a specific commit to a previous state. It allows you to undo changes and return to a previous point in the commit history.
There are a few different ways to perform a rollback in Git, depending on the specific situation and your requirements. Here are a couple of common scenarios:
1. Rollback a single commit:
If you want to undo the changes introduced by a specific commit while keeping the subsequent commits intact, you can use the `git revert` command. This command creates a new commit that undoes the changes made by the specified commit.
git revert
The `` represents the identifier of the commit you want to revert, such as the commit hash or a reference like a branch or tag name. Git will create a new commit that applies the inverse of the changes introduced by the specified commit.
2. Rollback multiple commits:
If you want to remove a series of commits and make it as if they never happened, you can use the `git reset` command. This command allows you to move the branch pointer to a previous commit, effectively discarding the commits that follow.
git reset
The `` specifies the commit to which you want to roll back. Git will move the branch pointer to this commit and discard the subsequent commits. By default, this command preserves the changes introduced by the discarded commits as unstaged changes in your working directory.
If you want to completely discard the changes introduced by the rolled-back commits, you can use the `--hard` option:
git reset --hard
Note: Exercise caution when using the `git reset` command with the `--hard` option, as it permanently removes the changes from your repository.
Conclusion :
It's important to note that rolling back commits modifies the commit history, so it's generally recommended to avoid rolling back commits that have already been shared with others. Instead, consider creating a new commit that introduces the desired changes or communicating with collaborators to coordinate any necessary changes.
Recommend
-
75
binlog-rollback.pl工具恢复mysql数据
-
57
Android Pie (Android 9)just went live today for theGoogle Pixel, GooglePixel 2, andeven the Essential Phone. We’re learning as much as we can about the release from interviews (the GooglePixel 3
-
81
All Xiaomi smartphones and tablets will have anti-rollback protection enabled. What is it and how do you avoid bricking your device because of it?
-
40
README.md
-
131
README.md
-
27
Published in October 2019 Welcome to Bite-sized Kubernetes learning— a regular column on the most...
-
18
1. 介绍 在发现有些commit出错时,可使用Hudi提供的rollback回滚至指定的commit,这样可防止出现错误的结果,并且当一次commit失败时,也会进行rollback操作,保证一次commit的原子性。 2. 分析 rollback...
-
13
最近使用 sqlmock 编写单元测试时遇到一个问题。现有这样的代码: defer func() { if err != nil { err = tx.Rollback() ... } } err = tx.Commit()...
-
16
Usually, database people are familiar with table fragmentation with DELETE statements. Whenever doing a huge delete, in most cases, they are al...
-
13
Git: remove, reset and rollback commits Posted: 2011-09-08 - Last updated: 2019-06-05 Tagged
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK