0

in the following image, when I git revert changeA, does my head stay at its original place and I have all the changes except for changeA?

Or I will loose all the changes from A to head and my head will be reset to the children of A ?

Sorry for the simple question in advance. enter image description here

user1836957
  • 427
  • 2
  • 9
  • 24

2 Answers2

0

You will keep your history. What git revert actually does is add a new commit which undoes the changes of the specified commit.

source:

https://git-scm.com/docs/git-revert

enter image description here

SomeGuy
  • 485
  • 3
  • 12
  • so then to have the commit back again, do I do git checkout A ? by doing that do I get all of of history back as original? – user1836957 May 17 '18 at 22:24
  • Yes, if you wanted to recommit that change you could git checkout A. You would maintain your whole history tree, including the history of your reversion. Your checkin would apply on top of the reversion, and would coincidentally have the same code as your reverted checkin. – SomeGuy May 17 '18 at 22:26
  • @someguy Ist ist much simpler to revert the reverted commit again. – A.H. May 18 '18 at 05:49
  • @A.H. I agree, I misread his question as 'Could I do this to resolve the issue?' rather than 'How should I resolve the issue?' Reverting the commit which reverted the functionality is easier and has the added bonus of being more idiomatic. – SomeGuy May 18 '18 at 14:49
0

Neither of them, it will create a new commit reverting the changes you made, keeping the your history.

https://www.atlassian.com/git/tutorials/undoing-changes/git-revert

Samuel Dias
  • 169
  • 5