I have a file which contains sensitive datas so I don\'t want to push content of this file to remote server.
To achiev
Well, this is a cruddy solution, but seems to work reasonably well (though it is only lightly tested):
Create a file named git-checkoutsw
somewhere in your PATH
, with the following content:
#!/bin/bash
ignored=( $(git ls-files -v | grep "^S " | cut -c3-) )
for x in "${ignored[@]}"; do
git update-index --no-skip-worktree -- "$x"
done
git checkout -m $@
for x in "${ignored[@]}"; do
git update-index --skip-worktree -- "$x"
done
The script captures the list of ignored files, unignores them, checks out the new branch with -m
(for merge) and whatever other parameters have been specified, and then ignores them again.
Now you can do git checkoutsw
instead of git checkout
.