Keep tags when forking a GitHub repository

Forking a repository with GitHub doesn’t bring its tags (or releases) along. Here’s how to update your fork with the upstream’s tags. Releases will still be missing. (Adapted from Update git fork with tags.sh)

# Clone your fork of the upstream repo
git clone https://github.com/my_team/my_fork.git
cd my_fork
# Add your fork's upstream as a remote
git remote add upstream https://github.com/upstream_team/upstream_repo.git

# Fetch from upstream
git fetch upstream
# Rebase onto upstream
git rebase upstream/main

# Push to your fork's remote
git push
git push --tags
Ben Fox @fox