If you want to keep tracking myfile.txt
on master
but deleted from mybranch
, then you simply need to delete it and commit the delete.
git checkout -b mybranch
rm myfile.txt
git commit -am "delete myfile.txt"
Now when you checkout master
, you’ll see your file returned and when you checkout mybranch
it will be gone again.
Note that if you merge mybranch
into master
, it will be deleted on master
then too.