GIT - cheat sheet
Install (Windows)
https://git-scm.com/
https://desktop.github.com/
set up new repo
(createInit gitnieuwe repo
In web gui first)/srv/repo
git init
git add .gitignore
touch README.md
git add README.md
git remote add myOrigin git@github.com:maxbis/examengesprekken
git push -u origin masterssh key
add ~/.ssh/id_rsa.pub in git hub web guiadd file
git addmkdir <file nameREPO>update repo
git commit -a -m "comment"
git pushGet updated files
git pullOverwrite local changes
git reset --hard
git pullNew clone - install new
git clone https://github.com/maxbis/examengesprekken
// for Ubuntu server
sudo chgrp -R www-data examengesprekkenGo to older version
git reset --hard 0ad5a7a6.....Git clear cache (if ignore file is changed)
git rm --cached configList all tracked files
git ls-tree -r HEAD --name-onlyGit issues with .ignore
git rm -r --cached .
git add .
git commit -m "Stop tracking files that are now ignored"Init new repo
cd path/to/class-cloud
git init git add .
git commit--bare -m "Initial commit"-initial-branch=main <create new repo on githibREPO>
git remote add origin https://github.com/maxbis/class-cloud.git
git push -u origin master
<on Linux>
git clone https://github.com/maxbis/class-cloud.git
Set Remoteup Githook &&script Checkfor gitauto remote
SSH key
deployments
ssh-keygenIn /srv/repo/<REPO>/hooks/
ln -ts ed25519/srv/git/.scripts/post-receive -C.
Local
git remote set-url originqool git@github.com:USERNAME/REPO.gitssh://<user>@<server>:1611/srv/git/<project>
git remotepush -vu qool main
Testpost-receive
Connection
The name of the git repostitory is the name of the directory in the document root.
ssh#!/bin/bash
set -Teuo git@github.compipefail
#NAME="imposer"
GIT_DIR="$(git rev-parse --absolute-git-dir)"
NAME="$(basename -- "$GIT_DIR")"
TARGET="/var/www/qool/${NAME}"
BRANCH="main"
GIT_DIR="/srv/git/${NAME}"
while read -r oldrev newrev refname; do
if [ "$refname" = "refs/heads/$BRANCH" ]; then
echo "Deploying $BRANCH to $TARGET..."
git --git-dir="$GIT_DIR" --work-tree="$TARGET" checkout -f "$BRANCH"
# optional: composer install, cache clear, reload apache, etc.
# cd "$TARGET" && composer install --no-dev
# sudo systemctl reload apache2
fi
done