Gitignore

master
Sebastian Preisner 7 years ago
parent f12a7acc62
commit 6705af5cbb

@ -0,0 +1,24 @@
# Remove file from git versioning and add to .gitignore
#########################################################
gitignore() {
# Current Folder a Git Repository?
if ! git rev-parse --is-inside-work-tree &> /dev/null ; then
echo "Current folder is no Git Repository"
return 1
fi
gitworktree=`git rev-parse --show-toplevel` # found on https://stackoverflow.com/questions/12293944/how-to-find-the-path-of-the-local-git-repository-when-i-am-possibly-in-a-subdire
# Create .gitignore if not exist
if [ ! -e "${gitworktree}/.gitignore" ]; then
echo "Creat new ${gitworktree}/.gitignore file"
touch ${gitworktree}/.gitignore
fi
for file in "$@"; do
# Remove file from history
echo "removing $file from git history"
git rm --cached -r "$file"
echo $file >> .gitignore
done
}
Loading…
Cancel
Save