golb

Git

Submodules

Dans un repository, on peut mettre des liens vers d'autres repo, puis on clone en faisant

git submodule update --recursive --init

Reset history of a repo

git checkout --orphan newBranch
git add -A  # Add all files and commit them
git commit
git branch -D master  # Deletes the master branch
git branch -m master  # Rename the current branch to master
git push -f origin master  # Force push master branch to github
git gc --aggressive --prune=all     # remove the old files

See public ssh keys

https://github.com/USERNAME.keys
https://gitlab.com/USERNAME.keys

GIT config

# show the config
git config --list --global

# change the config
git config --global user.name "n4n5"

Commits stats

git shortlog -sn

pre-commit

# install pre-commit
python -m pip install -u pre-commit
# install pre-commit hook
python -m pre_commit install

# useful command
python -m pre_commit run --all-files

Add multiple push URLs

git remote set-url --add --push [remote] [original_repo_URL]
git remote set-url --add --push [remote] [second_repo_URL]
git remote -v

Change commit date

changeCommitDate() {
  VARIABLE="${1:-3}"
  printf 'DAT=$(date --date "%s days ago" -R) GIT_AUTHOR_DATE=$DAT GIT_COMMITTER_DATE=$DAT git commit -m "message"\n' "$VARIABLE"
}