2016-09-29 09:46:39 +05:30
|
|
|
# Reverting changes
|
|
|
|
|
|
|
|
> [Introduced][ce-1990] in GitLab 8.5.
|
|
|
|
|
|
|
|
GitLab implements Git's powerful feature to [revert any commit][git-revert]
|
2018-03-17 18:26:18 +05:30
|
|
|
with introducing a **Revert** button in merge requests and commit details.
|
2016-09-29 09:46:39 +05:30
|
|
|
|
|
|
|
## Reverting a Merge Request
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
NOTE: **Note:**
|
|
|
|
The **Revert** button will only be available for merge requests
|
|
|
|
created since GitLab 8.5. However, you can still revert a merge request
|
|
|
|
by reverting the merge commit from the list of Commits page.
|
2016-09-29 09:46:39 +05:30
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
NOTE: **Note:**
|
|
|
|
The **Revert** button will only be shown for projects that use the
|
|
|
|
merge method "Merge Commit", which can be set under the project's
|
|
|
|
**Settings > General > Merge request**. [Fast-forward commits](fast_forward_merge.md)
|
|
|
|
can not be reverted via the MR view.
|
|
|
|
|
2016-09-29 09:46:39 +05:30
|
|
|
After the Merge Request has been merged, a **Revert** button will be available
|
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
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
![Revert Merge Request](img/cherry_pick_changes_mr.png)
|
2016-09-29 09:46:39 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
After you click that button, a modal will appear where you can choose to
|
|
|
|
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
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
After the merge request has been reverted, the **Revert** button will not be
|
2016-09-29 09:46:39 +05:30
|
|
|
available anymore.
|
|
|
|
|
|
|
|
## Reverting a Commit
|
|
|
|
|
|
|
|
You can revert a Commit from the Commit details page:
|
|
|
|
|
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
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
After the commit has been reverted, the **Revert** button will not be available
|
2016-09-29 09:46:39 +05:30
|
|
|
anymore.
|
|
|
|
|
|
|
|
Please note that when reverting merge commits, the mainline will always be the
|
|
|
|
first parent. If you want to use a different mainline then you need to do that
|
|
|
|
from the command line.
|
|
|
|
|
|
|
|
Here is a quick example to revert a merge commit using the second parent as the
|
|
|
|
mainline:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
git revert -m 2 7a39eb0
|
|
|
|
```
|
|
|
|
|
|
|
|
[ce-1990]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/1990 "Revert button Merge Request"
|
|
|
|
[git-revert]: https://git-scm.com/docs/git-revert "Git revert documentation"
|