Useful Git (and GitHub) stuff
Create a new GitHub repository and clone it locally¶
This will create the directory myproject
and clone the repository into it.
Squashing¶
Squash all the commits between your current HEAD and origin/main
into a single new commit.
Switching default branch¶
https://www.git-tower.com/learn/git/faq/git-rename-master-to-main
git branch -m master main
git push -u origin main
## May need to switch default branch in the UI, or use the gh CLI
gh repo edit owner/repo --default-branch main
git push origin --delete master
Updating fork¶
How to update a fork to have the same branches/tags as upstream repository?
# Set up the upstream remote for your forked repository:
git remote add upstream https://github.com/owner/repo
# Verify the remote with:
git remote -v
# Fetch latest tags from the upstream repository:
git fetch --tags upstream
# Push all tags from local repository to the forked repository:
Run git push --tags origin