Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Checkout a specific commit #2499

Closed
MintPlayer opened this issue Apr 21, 2020 · 18 comments
Closed

Checkout a specific commit #2499

MintPlayer opened this issue Apr 21, 2020 · 18 comments

Comments

@MintPlayer
Copy link

MintPlayer commented Apr 21, 2020

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.

@olifantix
Copy link

olifantix commented Apr 22, 2020

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.

@keithalewis
Copy link

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.

@olifantix
Copy link

olifantix commented Nov 6, 2020

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?

@keithalewis
Copy link

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?

@EmilAlipiev
Copy link

@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.

@GF-Huang
Copy link

We need checkout a tag, not reset.

@firehorseuk
Copy link

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.

@willemgons
Copy link

Just ran into this - again!

@jweschenfelder
Copy link

I would love to have this feature, too.

@feland207
Copy link

feland207 commented Mar 28, 2021

I also would love to have this feature in vs code.
My current workaround was:

  1. open a terminal console
  2. run git log to find the commit-id
  3. copy id of the commit I want to checkout
  4. run git checkout commit-id

@fededim
Copy link

fededim commented May 6, 2021

Is it possibile to reopen this issue and reconsider it ?

@lucaspsilveira
Copy link

I would like to see this issue resolved too

@ghost
Copy link

ghost commented Nov 3, 2021

That seems to be a very basic feature to have. Can we reopen the request please?

@awhig
Copy link

awhig commented Nov 20, 2021

This is sorely needed

@Camenwolf
Copy link

Please add this.

@HappyNomad
Copy link

This issue was closed without explanation. I'm not sure how this repo works, but seems odd that it was closed by a non-Microsoft person. Can someone reopen it? Otherwise, how about we create a new issue?

@pjmlp
Copy link

pjmlp commented Jan 5, 2022

It will be coming on the next Visual Studio release, https://developercommunity.visualstudio.com/t/i-want-to-be-able-to-git-checkout-an-old-commit-fr/648233

As side note, for this kind of issues the Developer Community is a better place to complain.

@kabua
Copy link

kabua commented Aug 2, 2022

@olifantix you wrote "I do not see why either would be a "nonintuitive workaround". How would do it using checkout instead?"

The fact that several other developers and I had to come to this page looking for answers clear states this is not a nonintuitive workaround

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests