debian-mirror-gitlab/doc/user/project/merge_requests/revert_changes.md

65 lines
2.4 KiB
Markdown
Raw Normal View History

2019-09-04 21:01:54 +05:30
---
2020-10-24 23:57:45 +05:30
stage: Create
2021-04-17 20:07:23 +05:30
group: Code Review
2021-02-22 17:27:13 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2019-09-04 21:01:54 +05:30
---
2016-09-29 09:46:39 +05:30
2021-11-11 11:23:49 +05:30
# Revert changes **(FREE)**
2016-09-29 09:46:39 +05:30
2019-09-04 21:01:54 +05:30
You can use Git's powerful feature to [revert any commit](https://git-scm.com/docs/git-revert "Git revert documentation")
by clicking the **Revert** button in merge requests and commit details.
2016-09-29 09:46:39 +05:30
2021-11-11 11:23:49 +05:30
## Revert a merge request
2016-09-29 09:46:39 +05:30
2021-02-22 17:27:13 +05:30
NOTE:
2021-04-17 20:07:23 +05:30
The **Revert** button is shown only for projects that use the
2019-02-15 15:39:39 +05:30
merge method "Merge Commit", which can be set under the project's
**Settings > General > Merge request**. [Fast-forward commits](fast_forward_merge.md)
2021-04-17 20:07:23 +05:30
can not be reverted by using the merge request view.
2019-02-15 15:39:39 +05:30
2021-04-17 20:07:23 +05:30
After the merge request has been merged, use the **Revert** button
2018-03-17 18:26:18 +05:30
to revert the changes introduced by that merge request.
2016-09-29 09:46:39 +05:30
2021-04-17 20:07:23 +05:30
![Revert merge request](img/cherry_pick_changes_mr.png)
2016-09-29 09:46:39 +05:30
2021-04-17 20:07:23 +05:30
After you click that button, a modal appears where you can choose to
2018-03-17 18:26:18 +05:30
revert the changes directly into the selected branch or you can opt to
create a new merge request with the revert changes.
2016-09-29 09:46:39 +05:30
2021-04-17 20:07:23 +05:30
After the merge request has been reverted, the **Revert** button is no longer available.
2016-09-29 09:46:39 +05:30
2021-11-11 11:23:49 +05:30
## Revert a commit
2016-09-29 09:46:39 +05:30
2019-09-04 21:01:54 +05:30
You can revert a commit from the commit details page:
2016-09-29 09:46:39 +05:30
2018-03-17 18:26:18 +05:30
![Revert commit](img/cherry_pick_changes_commit.png)
2016-09-29 09:46:39 +05:30
2018-03-17 18:26:18 +05:30
Similar to reverting a merge request, you can opt to revert the changes
directly into the target branch or create a new merge request to revert the
changes.
2016-09-29 09:46:39 +05:30
2021-04-17 20:07:23 +05:30
After a commit is reverted, the **Revert** button is no longer available.
2016-09-29 09:46:39 +05:30
2021-04-17 20:07:23 +05:30
When reverting merge commits, the mainline is always the
first parent. If you want to use a different mainline, you need to do that
2016-09-29 09:46:39 +05:30
from the command line.
2021-04-17 20:07:23 +05:30
Here's an example to revert a merge commit using the second parent as the
2016-09-29 09:46:39 +05:30
mainline:
2020-03-13 15:44:24 +05:30
```shell
2016-09-29 09:46:39 +05:30
git revert -m 2 7a39eb0
```
2019-09-04 21:01:54 +05:30
<!-- ## Troubleshooting
Include any troubleshooting steps that you can foresee. If you know beforehand what issues
one might have when setting this up, or when something is changed, or on upgrading, it's
important to describe those, too. Think of things that may go wrong and include them here.
This is important to minimize requests for support, and to avoid doc comments with
questions that you know someone might ask.
Each scenario can be a third-level heading, e.g. `### Getting error message X`.
If you have none to add when creating a doc, leave this section in place
but commented out to help encourage others to add to it in the future. -->