git add -p
git commit -v
git push --force-with-lease
# show the config
git config --list --global
# change the config
git config --global user.name "n4n5"
git submodule update --recursive --init
# commits stats
git shortlog -sn
# empty commit (useful to trigger CI)
git commit --allow-empty -m "Trigger CI"
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
https://github.com/USERNAME.keys
https://gitlab.com/USERNAME.keys
# 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
git remote set-url --add --push [remote] [original_repo_URL]
git remote set-url --add --push [remote] [second_repo_URL]
git remote -v
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"
}
GIT_EDITOR=vi git rebase -i HEAD~10
git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| sed -n 's/^blob //p' \
| sort --numeric-sort --key=2 \
| tail -n 10 \
| cut -c 1-12,41- \
| $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
git log --all --find-object=OBJECTID
git fetch -u https://codeberg.org/org/repo master:master-local
git switch master-local
Useful to know which commit is wrong
git checkout master
git bisect start
git bisect bad # mark master as bad
# go to a commit where is was working
git checkout "$MY_WORKING_COMMIT"
git bisect good
# bisect will automatically move to the commit in between
# do your test
git bisect bad # if commit is not working
git bisect good # if commit is working
# bisect will again move you to a commit to test
# an finally gives you the commit which broke
# then to quit
git bisect reset