Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doing a Git stash, or anything git related deletes the entire undo tree #146

Open
dagadbm opened this issue Jan 27, 2023 · 6 comments
Open

Comments

@dagadbm
Copy link

dagadbm commented Jan 27, 2023

I have lost hours of work because of this in the past and it continues to happen.

It super frustrating, I know need to re-write an entire file which is going to delay my work.

I dont understand why doing any kind of git movements like git stash or git checkout etc completely deletes the undotree.

Is there something you can do to prevent this on your side?

@dagadbm
Copy link
Author

dagadbm commented Jan 27, 2023

Thank god I had an opened nvim and I managed to recover this file...

Why is it that if I close nvim , do some git actions and then open it the undofile gets competely deleted?

I cant find anything about this behavior online

@mbbill
Copy link
Owner

mbbill commented Jan 27, 2023

Glad to hear you've got your data back. I've been there and I know how it feels when important data got lost like that. I think it's an VIM internal behavior but I can't find anywhere mention it in the vim documents. I did find some user wikis mentioned it though, e.g. https://vim.fandom.com/wiki/Using_undo_branches

However, note that if a file is modified externally without Vim, Vim will not be able to read the undo history back when you start editing the file again and the undo tree information will be lost. There is no way to get it back.

One of the safeguard is to enable the backup file. I personally do not use it as I'm aware of the above mentioned behavior but you can try if you're unsure.

@dagadbm
Copy link
Author

dagadbm commented Jan 28, 2023 via email

@mbbill
Copy link
Owner

mbbill commented Jan 28, 2023

So how do you prevent these issues? I found that page and I enabled this backup stuff and swap files just in case.

You mean me or the undotree plugin?

@dagadbm
Copy link
Author

dagadbm commented Jan 28, 2023 via email

@mbbill
Copy link
Owner

mbbill commented Feb 1, 2023

You because from what I understand there's nothing the plug-in can do right?

That's right.
I'm not seeing this issue very often because the way I use the undotree with git is a bit different. The undotree handles small changes within an edit session, and git takes care of the larger changes throughout the repo. I always double-check and make sure all opening editors are either saved or closed before running git commands.

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

No branches or pull requests

2 participants