GIT

General

Clone private repo with GitHub Token:

git clone https://username:password@github.com/username/repo_name.git

Default Branch

Change local branch name for new inits:

git config --global init.defaultBranch main

Update after remote renaming:

git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a

Remove Git history

Remove all history(make sure you have the backup) using:

cat .git/config  # note <github-url>
rm -rf .git

Reconstruct the git repo with the current content:

git init
git add .
git commit -m ":tada:"

Push the commit to github

git remote add origin <github-url>
git push -u --force origin master

Hotfix

Checkout latest tag and create new branch:

git checkout tags/<tag_name> -b <branch_name>

Publish branch and create a new release from branch

Commit in past

git commit --date="1 day ago" -m "..." -a

Last updated