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
130
votes
6 answers

Revert a merge after being pushed

Steps I performed: I have two branches branch1 and branch2, $git branch --Initial state $branch1 $git checkout branch2 $git pull origin branch1 --Step1 I resolve the conflicts and did a $git commit -m "Merge resolved" then $git checkout…
Bijendra
  • 9,467
  • 8
  • 39
  • 66
114
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
  • 6,667
  • 9
  • 47
  • 74
100
votes
3 answers

I need to pop up and trash away a "middle" commit in my master branch. How can I do it?

For example, in the following master branch, I need to trash just the commit af5c7bf16e6f04321f966b4231371b21475bc4da, which is the second due to previous rebase: commit 60b413512e616997c8b929012cf9ca56bf5c9113 Author: Luca G. Soave…
Luca G. Soave
  • 12,271
  • 12
  • 58
  • 109
97
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
  • 17,104
  • 45
  • 172
  • 321
78
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,732
  • 7
  • 42
  • 57
78
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
  • 15,824
  • 16
  • 93
  • 136
69
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
  • 983
  • 2
  • 7
  • 15
66
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,399
  • 2
  • 15
  • 22
64
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
  • 6,192
  • 12
  • 65
  • 89
62
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
  • 9,801
  • 5
  • 21
  • 9
57
votes
3 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
  • 4,293
  • 6
  • 37
  • 65
54
votes
3 answers

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

To help in my knowledge of git so I can use it day to day, what is the difference between: revert amend rollback undo What are they and what do they do?
gosbi
  • 755
  • 1
  • 6
  • 13
54
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
  • 761
  • 1
  • 9
  • 17
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
  • 165,801
  • 69
  • 278
  • 343
41
votes
5 answers

Reset/revert a whole branch to another branches state?

I have a branch A and a branch B (and some other branches). Lets say A's commit history looks like: commit 5 commit 4 commit 3 ... And B's commit history: some other commit commit 4 merge of other stuff from branch C (into branch B) commit…
daniel451
  • 10,626
  • 19
  • 67
  • 125
1
2
3
32 33