I cloned a repository a few days back and to make the cod run, I needed to modify the class path. Today I was told to pull X branch which I did using git pull
.
Now when I do git checkout X
, I get an warning for my classpath file
Stash or commit it to prevent local changes from being overwritten.
To recreate this warning, I tried two scenarios in other projects.
1st Scenario
In a git repo. Make changes in a file and not commit it. Then create a new branch and checkout to it. In that case it does not throw this warning.
2nd Scenario
In another repo,
- Commit a new file.
- Create a branch, checkout to that branch and make changes to that files and commit it
- Switch back to master, make local changes and not commit it. Then if I invoke
git checkout X
it throws that warning.
I don't really know what is the logic behind git showing this warning? Obviously, I can see these two scenarios and notice that they give different results. But I don't know, what git looks for to throw this warning.
Could someone please explain this to me and how this explains the warning I saw with my classpath file?