From 8fd07fd9f6702d0b3536ca52db8fb017def252b4 Mon Sep 17 00:00:00 2001 From: qued <64741807+qued@users.noreply.github.com> Date: Fri, 26 Sep 2025 11:36:56 -0500 Subject: [PATCH] feat: Add simple script to sync fork with local branch (#4102) #### Testing: From the base folder of this repo, run: ```bash ./scripts/sync_fork.sh git@github.com:aseembits93/unstructured.git optimize-_assign_hash_ids-memtfran ``` Check to make sure the only remote is `origin` with: ```bash git remote ``` Check the diff from `main` with: ```bash git diff main ``` --- scripts/sync_fork.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 scripts/sync_fork.sh diff --git a/scripts/sync_fork.sh b/scripts/sync_fork.sh new file mode 100755 index 000000000..dde45304f --- /dev/null +++ b/scripts/sync_fork.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Simple script to recreate a fork branch as a new branch in the current repository +# Usage: ./sync_fork.sh + +set -e + +if [ $# -ne 2 ]; then + echo "Usage: $0 " + echo "Example: $0 https://github.com/user/fork.git feature-branch" + exit 1 +fi + +FORK_URL="$1" +FORK_BRANCH="$2" + +echo "Adding fork as remote..." +git remote add fork "$FORK_URL" 2>/dev/null || git remote set-url fork "$FORK_URL" + +echo "Fetching fork..." +git fetch fork + +echo "Creating new branch '$FORK_BRANCH' with fork's changes..." +git checkout -b "$FORK_BRANCH" "fork/$FORK_BRANCH" + +echo "Removing fork remote..." +git remote remove fork + +echo "Done! You're now on branch '$FORK_BRANCH' with the fork's changes. Fork remote has been removed."