Skip to content

Instantly share code, notes, and snippets.

@rueycheng
Last active February 12, 2023 14:44
Show Gist options
  • Save rueycheng/97a9f5415ff64db8a5e06105f694bd6c to your computer and use it in GitHub Desktop.
Save rueycheng/97a9f5415ff64db8a5e06105f694bd6c to your computer and use it in GitHub Desktop.
Some useful git recipes

Clear out Git local/remote repos

https://stackoverflow.com/a/13102849

git checkout --orphan new_branch
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

Merge diffs from 'master' into a commit to 'public'

https://stackoverflow.com/a/14885097

git checkout public
git merge --squash master
git commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment