I recently ran some code and clearly saw it working.
I then switched to a different branch and when I switched back to my starting branch the thing i had observed working moments before stopped working.
After carefully checking the file It turns out that some code in one particular file had dissapeared.
1) Git did not warn me that I had un-committed changes or any other warning before switching branches.
2) Some changes which were made AFTER the missing code was written are still in the head commit of the branch in question both locally and on gitlab - I am absolutly certain that these changes were made AFTER the missing code was made and i have a witness to support me on this.
3) Only one file is effected and the later code which was persisted in a git commit is from other files.
What could have caused this?
This is really surprising because Git is specifically designed to make it really hard for you to lose data without at least being warned. Specifically:
> Git did not warn me that I had un-committed changes or any other warning before switching branches.
I just ran some experiments using Git version 2.15.1. I created a new file, edited a file, and edited a file and staged it via `git add`. Then I attempted to change branches. This is the error message I got:
error: Your local changes to the following files would be overwritten by checkout: foo.md Please commit your changes or stash them before you switch branches. error: Your local changes to the following files would be overwritten by checkout: bar.md Please commit your changes or stash them before you switch branches. Aborting
Note that there are only two files mentioned. The third file is the brand new file. If I undo the changes and only have the brand new file and switch branches, the branch is changed with no error message. This is because git doesn't do anything to files it doesn't know about, including files in subdirectories it doesn't know about. And you have to specifically add files to git for it to know about them, so new files are untouched.
So my only theory is that you:
Other than that, I can't think of anything.