Questions tagged [git-revert]

Revert changes of a commit in a Git repository

git revert allows you to revert some existing commits within a Git repository.

Popular questions

See also

References

$ git revert --help
404 questions
24
votes
1 answer

What is the difference between "Revert Commit" and "Undo Commit" in IntelliJ IDEA?

In IntelliJ Ultimate IDEA 2019.3 (not sure when it was introduced) we have "Revert Commit" and "Undo Commit" options in the Version Control -> Log Tab. What is the difference between those two options?
Marian Klühspies
  • 12,202
  • 12
  • 70
  • 108
23
votes
5 answers

Composer revert packages

I am building a new app in Symfony 2.1. I am using a lot of bundles pulled in using composer. A lot of these bundles have problems with this latest version of Symfony and I am having to go into the /vendor folder to identify the issues. This means…
lopsided
  • 2,160
  • 6
  • 25
  • 38
21
votes
2 answers

Revert a merge commit from a protected branch on GitHub.com

We have protected our develop branch on GitHub so that nobody downstream can push their commit directly. The commits need to go through specific feature branch and get merged through a pull request. There came a scenario where a feature branch is…
nak
  • 646
  • 1
  • 7
  • 21
18
votes
4 answers

Git revert certain files

I want to do a revert of a commit, but only for some files. (Not a checkout; a revert. If you are unfamiliar with the difference, keep reading.) I tried this git revert --no-commit abcdef123456 -- my/path/to/revert And I got this error fatal:…
Paul Draper
  • 64,883
  • 37
  • 172
  • 246
17
votes
3 answers

How to undo the last commit in git, but keep my changes as unstaged?

I've made a commit, but now it is kind of difficult to see what I all changed. I can off course do a git diff, but I'd rather undo the last commit and keep all my changes in tact so that my IDE (PyCharm) simply shows me which files have been…
kramer65
  • 39,074
  • 90
  • 255
  • 436
17
votes
2 answers

how to finish reverting a commit, and how to revert a lot of commits

This has to be simple, but I can't find it in git-scm. I've been making a lot of small commits to a public project, and all of my work is bad. I want to remove everything that I've done. Some I've just committed locally, some I've pushed to 'origin…
Pat Farrell
  • 321
  • 1
  • 2
  • 6
16
votes
2 answers

Git Revert a Revert for a Merge

I had a feature branch created, let's say feature/branch1 on github. I created a pull request for it and got it merged. When it reached our pipeline, we figured there was a problem and we got it reverted using the Revert button on Git This created…
Serendipity
  • 883
  • 1
  • 8
  • 17
16
votes
1 answer

git revert several specific commits

The problem: A branch has good commits interleaved with undesired ones. Attempted solution: git revert hash5 hash8 hash9 hash23 What I thought this would do is that it'd apply all specified commits, and then let me sort out any conflicts. What I…
15
votes
1 answer

git: revert all committed files in a directory to master

I have a feature branch feature-1-branch created from master. A lot of time as passed and I created a lot of commits on feature-1-branch. Now I want to revert commit all changes in a specific directory, lets say src/modules/feature-2 I made in…
Frank Adrian
  • 1,103
  • 12
  • 23
15
votes
1 answer

In git, how do you revert a file back to 3 commits ago?

I changed an image file in git and it was 2 commits ago. How do I go back to 2 previous commits ago? What is the easiest method of doing this file revert via the command line with the least amount of commands required?
Patoshi パトシ
  • 16,523
  • 2
  • 19
  • 33
14
votes
1 answer

Git revert failed

I made several commits (commit1/2/3), I changed my working directory without stashing. Then I wanted to go back several commits ago. So I git revert commit1 commit2 commit3, but I was told to commit my changes (commit4), so I did it, and then I made…
epsilones
  • 10,137
  • 18
  • 57
  • 80
12
votes
2 answers

Revert only a single file of a pushed commit

Below is the the pushed commits history. Commit Changed Files Commit 1| (File a, File b, File c) Commit 2| (File a, File b, File c) Commit 3| (File a, File b, File c) Commit 4| (File a, File b, File c) Commit 5| (File a, File b, File c) I…
Aki T
  • 444
  • 4
  • 14
12
votes
2 answers

git selective revert (equivalent of `git revert --patch`)

Is there a preferred method of reverting part of a previous commit, along the lines of partially reverting unstaged changes (git checkout -p) and partially adding unstaged changes (git add -p)? i.e. I have a commit several (or even, many) commits…
Mahmoud Al-Qudsi
  • 26,006
  • 12
  • 71
  • 118
12
votes
3 answers

Git: How to reset after merging?

I've merged a master branch from a friend's repository into my working directory into branch_a using: git pull my_friend master I've discovered that the merged version has errors. To continue development I would like to revert to my last commit…
Jonathan
  • 84,911
  • 94
  • 244
  • 345
12
votes
4 answers

Restore deleted file not staged in git

I accidentally removed the entire directory of my source code...with a nice rm -r. I know, really bad; but fortunately, I had a git repo in the containing directory. Thus, git has a huge list of unstaged changes of deleted files. For example:…
Vance T
  • 453
  • 2
  • 4
  • 15
1 2
3
26 27