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
493 questions
41
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
  • 50,427
  • 120
  • 308
  • 488
41
votes
7 answers

How to roll back Git repo to first commit and delete all history

I'm learning how to use git these days and I had to do many hit-and-misses. Thus I needed to delete and create anew my remote and local repos. Is there a way to roll back to the first commit of the repo and delete all history after that? Basically a…
Aleksandar Savkov
  • 2,894
  • 3
  • 24
  • 30
40
votes
1 answer

Git confusion - how to revert local changes to latest remote push?

I have a local git repository, but things get wrong and complicated and I simply want to overwrite all the files in my local directory with the latest version of what is on the remote repository. This would be like a clone, but for an already setup…
user1738984
  • 584
  • 1
  • 5
  • 15
39
votes
3 answers

How to revert uncommitted changes to files of a certain type in git

I have a bunch of modified files in my git repository and a large number of them are xml files. How do I revert changes (reset modifications) of only the xml files?
Mujo Osmanovic
  • 931
  • 2
  • 11
  • 15
31
votes
4 answers

Reverting a series of pushed merges and commits in Git (without rewriting history)

Context One of my teammates mistakenly pushed some commits to our main development branch. We're a small, collocated team. Our remote repository is hosted on an internal server. Here is the top of our commit log (all these commits have already been…
leifericf
  • 2,324
  • 3
  • 26
  • 37
30
votes
3 answers

How to git revert a commit using a SHA

How can I revert a commit with a GIVEN SHA? I just want to remove the changes with a given SHA? I want to keep all the commits made BEFORE & AFTER the give SHA. I just want to remove changes of that specified SHA. I have read Revert to a commit by…
michael
  • 106,540
  • 116
  • 246
  • 346
27
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
  • 1,015
  • 1
  • 10
  • 19
27
votes
6 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,370
  • 6
  • 28
  • 40
26
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
  • 846
  • 2
  • 10
  • 26
26
votes
3 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
  • 421
  • 1
  • 4
  • 6
23
votes
1 answer

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
  • 612
  • 2
  • 7
  • 17
23
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
  • 78,542
  • 46
  • 206
  • 285
22
votes
3 answers

Why do I get conflicts when I do git revert?

I use Git, and I know that: git revert is used to create a new commit that will be identical to the past commit in the hash-code. For example, I have the following commits: 1f74a0e second commit e72d8b8 first commit I wanted to…
CrazySynthax
  • 13,662
  • 34
  • 99
  • 183
19
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,214
  • 13
  • 24
18
votes
4 answers

error: Reverting is not possible because you have unmerged files

When trying to revert a specific commit in git, I'm getting this error: $ git revert aaaf93201a28a57d540d633b1b723b8e513a47ed error: Reverting is not possible because you have unmerged files. hint: Fix them up in the work tree, and then use 'git…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
1 2
3
32 33