Visualstudio: Checkout a specific commit

Created on 21 Apr 2020  路  7Comments  路  Source: github/VisualStudio

Provide a more straightforward way to checkout a specific commit from the past
If at some point a bug has been introduced in my application, I want to revert to a previous state in my master/release branch to track the bug. But...

It appears that Git for VS (Team Explorer -> [branch] -> View History) does not have an options menu to checkout a specific commit.

Current method
The only way I can think of now to checkout a commit from the past is by

  • Right clicking the commit
  • View Details
  • Copy the commit ID
  • Open a console in your repo-folder
  • git checkout [commit-id]

Current method 2

  • Create a tag on the commit
  • Home
  • Tags
  • Checkout the tag

If a bug is introduced than you have to checkout one commit after another. Checking out commits like this would be a tedious work.

Describe the solution you'd like
Add a context-menu item to checkout a specific commit from a branch's history.

(Keeping in mind that the repository is in a detached state after this)

image

Similar issues
There already are requests like this, but they aren't conclusive.

Most helpful comment

Why create a new branch instead of calling git checkout? This seems like a nonintuitive workaround instead of making a standard git command available in the UI.

All 7 comments

The function you are looking for is:

  • New Branch ... and give it a new name, it will be based on that revision or
  • Reset + Delete Changes (--hard) (to stay in the current branch for whatever reason)
    if you just want to snoop around in that commit.

Why create a new branch instead of calling git checkout? This seems like a nonintuitive workaround instead of making a standard git command available in the UI.

Why create a new branch instead of calling git checkout? This seems like a nonintuitive workaround instead of making a standard git command available in the UI.

If at some point a bug has been introduced in my application, I want to revert to a previous state in my master/release branch to track the bug.

If you have a bug and want to track/handle it, you should create a new bugfix branch. The UI can do that ("New branch..."). If you just want to roll back to that ref, the UI can do that: ("Reset hard...") - I do not see why either would be a "nonintuitive workaround". How would do it using checkout instead?

git checkout
...copy a chunk of code no longer in master...
git checkout master
...paste it back in...
I don't want to create a branch and I don't want to reset, just peek at an older revision.
Why not expose checkout in the UI?

@olifantix I have a case now there is bug in my latest commit but I don't know which recent commit caused this bug. I went to 10 commit earlier with your suggestion using new branch reset and found out that 10 commit before it was working. Now i have to find out which of those 9 commits in between caused this error. I have to do 9 times a new branch and reset if use VS2019.
It may sound for you can you just now find through the file but when code base is too big and there can be many factors causing this bug and if i cannot simply found out and this is the only way.
A simple checkout can save my time dramatically.

We need checkout a tag, not reset.

I've got about 30 commits since I've to re-examine this bit of code that was working fine before. But somewhere along the way it's now not behaving as it should. Would be great to have checkout a commit. It would save me having to use something else.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tierninho picture tierninho  路  7Comments

grokys picture grokys  路  6Comments

laurentkempe picture laurentkempe  路  4Comments

jcansdale picture jcansdale  路  10Comments

AmbroiseCouissin picture AmbroiseCouissin  路  10Comments