Right now I have locally a credential file that I use locally to test my changes.
set_env.py defines environment variables that I use to log in a distant app
As I don't want to actually push the credentials, I pushed a dummy file which basically does nothing (as the environment variables are supposed to be already defined on the test server for example).
However, since I have a dummy file pushed to my branch, set_env.py is considered staged and I cannot change branches
git checkout other_branch
error: Your local changes to the following files would be overwritten by checkout: config/set_env.py Please, commit your changes or stash them before you can switch branches. Aborting A solution would simply to stash this file every time I want to switch branches (assuming I have no other modified staged and non-commited file)
git stash git checkout other_branch git stash apply However it becomes cumberstone to have to type 3 commands each time I want to change the branch I'm working on. Is there a way to tell git to consider this file as unstaged from now on ? (without deleting the file on the next commit)
Edit: @phd answer seems the most straightforward, however it does only work if I don't have any other staged uncommited file. Is there a solution where I could do what I want and still stash other files ?
Cheers