Skip to content

Instantly share code, notes, and snippets.

@shinshin86
Created December 4, 2023 23:36
Show Gist options
  • Save shinshin86/4785b9698f57fbebac729b89ffcbe653 to your computer and use it in GitHub Desktop.
Save shinshin86/4785b9698f57fbebac729b89ffcbe653 to your computer and use it in GitHub Desktop.
This shell script checks If the upstream remote is present, it proceeds to fetch all tags from the upstream repository and then pushes these tags to the origin remote repository.
#!/bin/bash
# Check if the upstream repository is set
upstream=$(git remote -v | grep upstream)
# Check if the upstream repository exists
if [ -z "$upstream" ]; then
echo "The upstream repository is not set."
else
echo "Upstream repository found. Fetching and pushing tags."
# Fetch tags from upstream and push them to origin
git fetch upstream --tags
git push origin --tags
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment