1

I decided I wanted to revert back from Version 31 to Version 69 on my Visual Studio Project (Its using GIT and TFS)

I was able to use the Team Explorer and press reset and seemingly go back to version 69 state.

However, now when I go to commit, all changes from commits 57 and 31 are staged to be committed, even though they are not in my Visual Studio Solution explorer.

I don't want the information from the new commits, I essentially just want version 69 to be the newest. Is there anyway for me to do that? enter image description here

user9758771
  • 109
  • 1
  • 8
  • 1
    `all changes from future commits are there waiting to be committed even though I can't see them` <-- I don't know what this actually means. Can you add some branch diagrams showing us what is going on? – Tim Biegeleisen Mar 18 '19 at 14:13
  • I just mean that in Visual Studio that the Solution Explorer is showing only the items that are in the current commit. But when I actually click commit, all of the items from future commits are staged to be committed, even though I can't see them on the Interface. – user9758771 Mar 18 '19 at 14:18
  • As well I just reverted back two commits on the Master Branch, I haven't branched anything. – user9758771 Mar 18 '19 at 14:24
  • Possible duplicate of [How to revert a Git repository to a previous commit](https://stackoverflow.com/questions/4114095/how-to-revert-a-git-repository-to-a-previous-commit) – Liam Mar 18 '19 at 14:38
  • *If* you've reset your local repository (hard I'm presuming) you then need to force push this to the server. Baring that please give us a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) of your problem. As it stands your question is very vague about what you've actually done and what the result of this was. – Liam Mar 18 '19 at 14:40
  • Also be aware `force push`ing can result in lose of data so use with caution – Liam Mar 18 '19 at 14:40
  • Alright I think I can figure it out from the possible duplicate...… Its kind of difficult for me to describe because I've been using the Visual Studio Team Explorer interface and not the Command Line. So I don't have a log of what happened. – user9758771 Mar 18 '19 at 14:51
  • The team explorer is just a shell to the command line, so you can run a reflog on the repo even if your using team explorer. My advice, VS GIT integration is rubbish, use command line or [GIT Extensions](https://sourceforge.net/projects/gitextensions/) – Liam Mar 18 '19 at 15:10
  • Noted - Thanks for the advice – user9758771 Mar 18 '19 at 16:19

1 Answers1

0

Although this question passed long time. I met one similar situation. I'm using VS with Git self.

I had mistaken on reset-hard to one old commit. All log and commit latest what I need was gone.

I'm tried to do following action.

  1. go to your solution and find hide folder .git.
  2. find log folder and open HEAD file. There must be one line include one commit you want but not show in VS. remember commit-id (2nd one in same line).
  3. open your cmd prompt.
  4. go to your git path. such as:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\cmd
  5. type cmd: git -C your solution folder+.git reset your commit id.
  6. Then go back to VS, those file still not back but you can find all change marked in view-Git change. Just select all change then cancel changes. All files related your commit should be back.

Reminder, I'm not sure if my solution is available for all situation. So it's better keep one more copy for your solution. Otherwise it takes more loss. :)

Feige
  • 1
  • 2