I was working on a branch and there was a need to fix something in the master branch. I was not ready to commit so I stashed my changes to try to go back. The pipeline of command that I used were:
git stash
git checkout master
git pull
==> fixed code in file file.py
==> made changes in file2.py that I don't want to keep
git add file.py
git commit -m'fixed stuff'
git push
git checkout initial_branch
git stash apply stash@{0}
Which gave me the error:
error: Your local changes to the following files would be overwritten by merge:
file2.py
Please, commit your changes or stash them before you can merge.
Aborting
I wonder what I did wrong what I should do in this case in the future.