I am using a script to automatically checkout the first commit of each month, for the last 12 months. Occasionally something strange happens and I am no longer allowed to checkout past commits. The error goes something like this:
error: Your local changes to the following files wold be overwritten by checkout:
db tests/framework.cpp
Please, commit your changes or stash them before you can switch branches. Aborting
This has happened many times (I am not editing any files, just checking them out). I usually just download a fresh copy of the repo from Github and start the process again and it works. But once it breaks I don't know how to fix it, and it keeps happening. Any thoughts?
Here is the iteration going on in my script, followed by the output of git status
for i in {12..1}
do
cd
cd git/mongodb/mongo
git checkout master
git checkout $(git rev-list --before "$(date -d "$(date +%Y-%m-01) -$i months 00:01" +%Y-%m)-01" -n 1 HEAD)
git checkout master
Git status:
On branch master
Changes not staged for commit:
modified: dbtests/framework.cpp
Untracked files:
SHA1.txt
SHA1.txt.
file
file.
no changes added to commit