gitkraken/vscode-gitlens

"apply Changes" has discarded all my changes.

b6pzeusbc54tvhw5jgpyw8pwz2x6gs opened this issue · 5 comments

Issue Type: Bug

  • There is the file named a.txt in the master branch.
  • I edited contents of a.txt and save in VS Code.
  • in GITLENS view, master -> 1 file changed -> a.txt -> mouse right click -> select "apply changes" to move changes into staged area.
  • But nothing happened except the changes were all gone.
  • Due to "apply changes" GITLENS, I lost all my work for two hours.

VS Code version: Code 1.24.1 (24f62626b222e9a8313213fb64b10d741a326288, 2018-06-13T17:41:50.128Z)
OS version: Darwin x64 17.5.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz (4 x 2500)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: enabled
video_decode: enabled
video_encode: enabled
vpx_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 4, 3, 3
Memory (System) 16.00GB (0.11GB free)
Process Argv /Applications/Visual Studio Code.app/Contents/MacOS/Electron -psn_0_9341160
Screen Reader no
VM 0%
Extensions (10)
Extension Author (truncated) Version
vscode-docker Pet 0.0.27
vagrant bbe 0.5.0
vscode-instant-markdown dba 1.4.2
githistory don 0.4.2
gitlens eam 8.4.1
vsc-material-theme Equ 2.3.0
prettier-vscode esb 1.5.0
mssql ms- 1.4.0
python ms- 2018.6.0
markdown-pdf yza 1.2.0

First, I'm really very sorry that you lost your work. 😢 I will add protection ASAP that will stop that from happening again, but the root of the issue is confusion about what Apply Changes does.

Apply Changes is to be used to take the changes from a file revision and apply those changes to your working copy. It is not for saving (or staging) your working changes. So given that, Apply Changes should have taken your working changes and applied them to your working copy (basically a no-op), but unfortunately there was a bug in the code that caused it to use the changes from HEAD rather than the working copy.

I will fix that ASAP and it will be in the next GitLens release. I am also changing the order of operations for how Apply Changes works. Before I would tell git to apply the requested changes to the working copy (git checkout) and then I would have vscode open the file. Instead, I will first have vscode open the file, and then have git update it. That way vscode will add the changes to the undo buffer, so that the changes could also be easily undone if needed.

Again I'm really sorry for the time and work lost.

Thank you for your quick response. I am always thankful for contributing the best git extension!!

Hey, I got the same issue 3 days of full work on a file is lost, exist a wat revert or check history within Visual Studio to get back my last data of the file.....

Sorry that you lost work, but what were the steps that caused it? This bug has been fixed so I'd like to understand if there are other issues lurking.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.