notebook/IT/git.md
2020-11-26 19:27:32 +01:00

41 lines
796 B
Markdown

# git
## delete a file only from git repository
`git rm -rf --cached`
## delete a file from complete history
be carefull can't push repo last time use
`git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch logbook.md" HEAD`
## example de déclencheur git
```bash
#!/bin/bash
GIT_REPO=`pwd`
SITE_NAME=notebook
TMP_GIT_CLONE="/tmp/$SITE_NAME"
PUBLIC_WWW="/usr/share/nginx/html/$SITE_NAME"
# get branch name
if ! [ -t 0 ]; then
read -a ref
fi
IFS='/' read -ra REF <<< "${ref[2]}"
branch="${REF[2]}"
if [ "master" == "$branch" ]; then
mkdir -p $TMP_GIT_CLONE
echo "download repo"
git clone --recursive $GIT_REPO $TMP_GIT_CLONE
cd $TMP_GIT_CLONE
export PATH="$HOME/.local/bin:$PATH"
make install -e BUILDDIR=$PUBLIC_WWW
echo "Cleaning up"
rm -Rf $TMP_GIT_CLONE
fi
exit
```