HelloCW
HelloCW

Reputation: 2235

Is there a Revert command of Git in Vs 2019?

There is a Revert command of Git in Android Studio 3.5.3, you can see Image 1. So I can use this command to give up all modification.

But I can't the Revert command in Vs 2019, I have installed Git Extensions, you can see Image 2.

How can I give up all modification in Vs 2019 when I use GitHub ?

Image 1 enter image description here

Image 2 enter image description here

Image 3 enter image description here

Upvotes: 1

Views: 2999

Answers (4)

Johan Donne
Johan Donne

Reputation: 3285

I did some reading about what the 'revert' button in Android Studio accomplishes, and it seems to me this is not a 'Git' Revert: it rolls back all the local changes that have not yet been committed. In Visual Studio there are two variants of this (none of which needs the Git Extensions):

  • to roll back changes in a document that has changes: right click and select 'source control' - 'Undo'

enter image description here

  • to roll back all changes in your project: in the 'Changes' Window, right click on the 'root' folder of the project and select 'Undo changes...'

enter image description here

Upvotes: 4

Radha Manohar
Radha Manohar

Reputation: 419

In order to get all the changes and revert to the previous commit,

git log, get the commit id of the commit you wish to get. git fetch origin <CommitId> will get the commit changes. git reset --hard FETCH_HEAD will apply the changes to your local repository and at the backend its revert which actually happens.

Upvotes: 1

Johan Donne
Johan Donne

Reputation: 3285

You can 'Revert' using the built in client: 'Changes' - 'Actions' - 'View history' ... Right click on specific commit and select 'Revert' in context menu:

enter image description here

You can Revert in the Git Extensions Window from the context menu (by right clicking, not via the command menu) for any commit:

enter image description here

Upvotes: 0

VonC
VonC

Reputation: 1323503

Your menu is done on the most recent commit, where you see "Undo last commit"

Check if "Revert" is visible when you trigger the same contextual menu on a commit which is not the last one.

Upvotes: 1

Related Questions