Skip to content


What Where
Official Page
Windows choco install git
Ubuntu sudo apt-get install git


Tools and Helper



Set global user name and email (remove --global flag for specific repo only):

git config --global "0xfab1"
git config --global ""

View current config: git config --global --list

Setup SSH login

Create new key

ssh-keygen -t ed25519
Check if service is running and add key
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
ssh-add -l

Copy this to github

cat ~/.ssh/

Test connection to github

ssh -T

Test to clone, commit and push on a repo

git clone
cd git-test/
chmod u+x
git add -f
git commit -m "adding script"
git push


  • Get all authors: git log | Where { $_ -match "Author" } | Select-Object -unique
  • Download a specific branch: git clone -b dependabot/npm_and_yarn/pug-3.0.1
  • List all files in a folder by last commit date: git ls-tree --name-only HEAD foldername/ | while read filename; do echo "$(git log -1 --format="%ci " -- $filename) $filename"; done | sort -r

Clean up

  • Delete all the objects w/o references: git prune --progress add --dry-run for a test
  • Aggressively collect garbage: git gc --aggressive

Remove Tags

Run this in your local repository of which you want to remove a tag/tags:

git fetch
git tag
git tag -d {tag-name}
git push origin :refs/tags/{tag-name}

Remove git history

Run this to remove the history of main:

git checkout --orphan latest_branch
git add -A
git commit -am "fresh start"
git branch -D main
git branch -m main
git push -f origin main

In any other cloned repositories, to do a "forceful" pull:

git fetch --all
git reset --hard origin/main

Rename master to main

Run this to rename the repo from master to main:

git branch -m master main
git checkout main
git push -u origin main
git push origin --delete master

other in the projekt need to do this:

git checkout master
git branch -m master main
git fetch
git branch --unset-upstream
git branch -u origin/main


Git ignores .gitignore with .gitignore in .gitignore

Init a new repository and added a .gitignore file containing ".gitignore" to instruct git to igntore the .gitignore file. Example:

git init .
echo ".gitignore" > .gitignore
git status


On branch trunk
No commits yet
nothing to commit (create/copy files and use "git add" to track)

A list of gitignore files based on prgramming language is available here.

Pretend to be busy

Do this on a clean machine

git config --global ""
git config --global "Busy Bee"

Clone an empty new repostory e.g.:

git clone
cd git-test

Run the script to create a commit for every day... e.g. since 1999.

chmod u+x

Run this script to add a commit every day from 2018 to 2022

for Y in {2018..2022}
    mkdir $Y
    cd $Y
    for M in {01..12}
        mkdir $M
        cd $M
        for D in {01..28}
            mkdir $D
            cd $D
            for i in {01..12}
                echo "$i on $M/$D/$Y" >
                export GIT_COMMITTER_DATE="$Y-$M-$D 12:$i:00"
                export GIT_AUTHOR_DATE="$Y-$M-$D 12:$i:00"
                git add -f
                git commit --date="$Y-$M-$D 12:0$i:00" -m "$i on $M $D $Y"
            cd ../
        cd ../
    cd ../
git push

To delete the entries run this:

git rm -rf 20**
git commit -am "cleanup"
git push