For a test I have a simple console app and I commit it (Initial). Then I add a comment and commit it (00). Then I change the comment and commit it (01)
Now I want to simply revert back to 00.
Changes | Actions | View History
right-click 00 | Revert
Are you sure you want to revert .... | Yes
At this point I get a conflict: Program.cs [both modified]. But why would that be a conflict -- I just want to revert to the previous version?. I click that and then I have options to:
Merge (button)
Edited on Source | Diff | Take Source (links)
Edited on Target | Diff | Take Source (links)
If I click Merge I see three different panes, all with different versions (source, target, and merge).
The source looks like my first version (initial), the target looks like my current version (01) and the merge looks like what I have chosen to to revert to (00).
If I close that window I get a dialog that asks if I want to accept the merge results -- and from there I am able to do the revert with the merged document.
Can you explain what is meant by the source and target panels (it seems like the target is my current version, but the source looks like a version even before this reversion that I want (it looks like initial!).
Ultimately I can keep the source panel, the target panel or the results of the merge, essentially reverting to any of those three choices. Is this the way the VS 2015 tool is intended to work? Key question: what if I just want to revert to the previous version's file completely without any merging?
Also... I noticed when I watched the Microsoft Build Demo on this tool they did a revert and did not have the problem I discussed above. https://channel9.msdn.com/Events/Build/2015/3-746 (see at the 7:30 mark).
Thank you!
p.s. I did not find documentation for how revert works for this tool on the Internet so if there is one please point that link and I will look there :)
Use the revert command to undo the changes made in commits pushed to shared branches. The revert command creates a new commit that undoes the changes made on a previous commit. The revert command doesn't rewrite the repository history, which makes it safe to use when you're working with others.
To revert changes made to a file in the working directory, just choose "revert changes" from the context menu in Visual Studio. Save this answer.
The purpose of the git revert command is to remove all the changes a single commit made to your source code repository. For example, if a past commit added a file named index.html to the repo, a git revert on that commit will remove the index.html file from the repo.
First, you'll need to find the ID of the revision you want to see. This assumes that you're developing on the default main branch. Once you're back in the main branch, you can use either git revert or git reset to undo any undesired changes.
If you select a commit to revert, Visual Studio does not "revert to" that point in time - it does a logical removal of the changes that commit introduced. It attempts to remove only the changes that were introduced in that commit.
Consider some series of commits for a single file:
Line one
Line two
Line three
Line four
Line five
Line one
Line 2
Line three
Line 4
Line five
Line ONE
Line 2
Line three
Line 4
Line FIVE
If you want to revert commit 2 - you are trying to undo the changes that it introduced, while retaining the changes introduced in commit 3. The results will be:
Line ONE
Line two
Line three
Line four
Line FIVE
However, there can be conflicts. If commit 2 had changed the same line that commit 3 had changed, the revert would fail with a conflict, and you would have to resolve it to continue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With