Git Recipes

git current branch squash to one commit

git reset --soft $(git rev-list --reverse --topo-order --first-parent HEAD | sed 1q)
git commit --amend -m "initial public commit"

Create a new clean_branch from the current branch

git branch clean_branch $(echo "clean branch" | git commit-tree HEAD^{tree})

misc notes

# Git pull over unclean working tree https://stackoverflow.com/questions/1125968/how-do-i-force-git-pull-to-overwrite-local-files

# Cleanup feature branches before merging into master https://www.jetbrains.com/help/pycharm/edit-project-history.html

# clear remote history https://www.systutorials.com/how-to-clear-git-history-in-local-and-remote-branches/

https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories#switching-remote-urls-from-https-to-ssh

## list remotes

git remote -v


## Add remotes

git remote add origin git@github.com:plataux/hive.git

## change and set remote access via SSH

git remote set-url origin git@github.com:REPO_OWNER/REPOSITORY.git

git remote set-url origin git@github.com:brainix/pottery

git remote set-url origin git@github.com:plataux/hive.git

git remote set-url origin git@github.com:plataux/hive.git

set remote access via HTTPs

git remote set-url origin https://github.com/REPO_OWNER/REPOSITORY.git