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
74
votes
1 answer

git revert --no-commit without staging

Usually the command git revert automatically creates some commits with commit log messages stating which commits were reverted. To avoid automatic commit there's the option -n (or --no-commit). But after this command, the reverted files are in the…
lornova
  • 5,917
  • 8
  • 39
  • 68
65
votes
2 answers

Can not push changes after using git reset --hard

I had a mistake and commit some changes to git which I should not have committed. After I made the commit, I pushed my changes. I then used the following commands to try and reset my changes. git reset --hard head Now I want to push this 'reset'…
mans
  • 14,494
  • 34
  • 144
  • 277
62
votes
13 answers

Visual Studio 2015 Git error message "Cannot pull/switch because there are uncommitted changes"

I am having difficulty in doing a pull from origin. I keep getting: "Cannot pull because there are uncommitted changes. Commit or undo your changes before pulling again. See the Output window for details." This also applies to switching branches.…
kwiri
  • 1,309
  • 1
  • 15
  • 22
59
votes
2 answers

What should I do when git revert aborts with an error message?

OK, so I'm getting an error sometimes when I try to revert a commit (with Git). All that I do is git revert and it gives me this message: error: could not revert hint: after resolving the conflicts, mark…
icnhzabot
  • 8,591
  • 5
  • 19
  • 9
58
votes
5 answers

How to revert last commit and remove it from history?

I did a commit and reverted with git revert HEAD^ just git log ➜ git:(master) git log commit 45a0b1371e4705c4f875141232d7a97351f0ed8b Author: Daniel Palacio Date: Tue Jan 17 16:32:15 2012 -0800 Production…
daniel
  • 9,178
  • 7
  • 38
  • 57
56
votes
2 answers

Reverting specific commits from git

I have a git tree with a lot of commits and a lot of files. Now, I want to revert specific commits that touch a file only. To explain: > git init Initialized empty Git repository in /home/psankar/specific/.git/ > echo "File a" > a > git add a ; git…
Sankar
  • 5,151
  • 10
  • 49
  • 75
51
votes
4 answers

Undo change in git (not rewriting history)

I made a change in a script and committed it. Then I made a few other changes, and pushed them to a remote repository and such. Then I realised that first change I mentioned was stupid, and want to undo it.. Can I "unapply" that commit, without…
dbr
  • 153,498
  • 65
  • 266
  • 333
51
votes
4 answers

Undoing a git pull --rebase

Hey I'm new to git and I need to undo a pull, can anyone help?!? So what I've done is... git commit git stash git pull --rebase git stash pop this created a bunch of conflicts and went a bit wrong. Now doing 'git stash list' reveals that my stash…
Thomas
  • 793
  • 2
  • 6
  • 14
49
votes
2 answers

hint: after resolving the conflicts, mark the corrected paths

git sometimes gives me this message on a conflict (during a revert or cherry pick) hint: after resolving the conflicts, mark the corrected paths What does this mean?
paullb
  • 3,995
  • 4
  • 34
  • 61
38
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
  • 564
  • 1
  • 4
  • 14
36
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
  • 891
  • 2
  • 11
  • 15
35
votes
2 answers

git revert not allowed due to a merge but no -m option was given

I am trying to revert to a certain 'hash' number in git, by using the 'revert' command. I am using the following command: git revert c14609d74eec3ccebafc73fa875ec58445471765 But, I am getting the following returned: error: Commit…
user3544484
  • 575
  • 1
  • 7
  • 17
33
votes
3 answers

What are the differences between 'revert', 'amend,' 'rollback', and 'undo' a commit?

Although I use Git pretty often, I'm still a beginner. Sometimes, I make a mistake but spot it only after I have committed it. At that point, I usually have to spend a long time on the Internet looking for the command I should use to get rid of it…
gosbi
  • 536
  • 1
  • 5
  • 10
30
votes
6 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,634
  • 3
  • 20
  • 30
29
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…
Leif
  • 1,969
  • 2
  • 20
  • 31
1
2
3
26 27