Understanding Git for Visual Studio 2015: Returns

For the test, I have a simple console application, and I commit it (Initial). Then I add a comment and commit it (00). Then I modify the comment and commit it (01)

Now I just want to go 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 changed]. But why will it be a conflict - I just want to return to the previous version ?. I click this and then I have options:

 Merge (button) Edited on Source | Diff | Take Source (links) Edited on Target | Diff | Take Source (links) 

If I click "Merge", I will see three different panels, 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 chose to go back to (00).

If I close this window, I get a dialog that asks if I want to accept the results of the merge - and from there I can return with the merged document.

Can you explain what the source and target panels mean (it seems that the goal is my current version, but the source code looks like the version before this reversal I want (it looks like the initial one!).

Ultimately, I can save the source panel, target panel, or merge results, essentially returning to any of these three options. Is VS 2015 the way it works? The key question is: what if I just want to completely go back to the previous file without merging?

Also ... I noticed that when I watched the Microsoft Build Demo demo on this tool, they made a refund and did not have the problem that I mentioned above. https://channel9.msdn.com/Events/Build/2015/3-746 (see mark 7:30).

Thanks!

ps I did not find documentation on how the reverse works for this tool on the Internet, so if there is one, specify this link and I will look there :)

+5
source share
1 answer

If you select a commit to return, Visual Studio will not return to this point in time - this will lead to a logical deletion of the changes made. He tries to remove only those changes that were made to this commit.

Consider some series of commits for a single file:

Commit 1

 Line one Line two Line three Line four Line five 

Commit 2

 Line one Line 2 Line three Line 4 Line five 

Commit 3

 Line one Line 2 Line three Line 4 Line five 

If you want to undo commit 2, you are trying to undo the changes made while keeping the changes made to commit 3. The results will be:

Return Commit 2

 Line one Line two Line three Line four Line five 

However, there may be conflicts. If commit 2 changed the same line as command 3, it will return with a conflict, and you will have to allow it to continue.

+10
source

Source: https://habr.com/ru/post/1234053/


All Articles