#!/bin/bash if [ "$#" -ne 2 ]; then printf "Usage: git-fork-sync " exit fi main_remote="$1" main_branch="$2" if git rev-parse --is-inside-work-tree >/dev/null 2>/dev/null; then printf "Trying to connect to remote %s...\n" "$main_remote" if git ls-remote --exit-code "$main_remote" >/dev/null 2>/dev/null; then git pull "$main_remote" "$main_branch" git push --force printf "\nSuccessfully resynced the forked repository.\n" else printf "\nRemote %s is unreachable for this repository.\nCheck if the name is correct and if it is, check if the remote url is correct.\n" "$main_remote" fi else printf "You are currently not in a git repository." fi