Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions scripts/sync_fork.sh
Original file line number Diff line number Diff line change
@@ -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 <fork_url> <fork_branch>

set -e

if [ $# -ne 2 ]; then
echo "Usage: $0 <fork_url> <fork_branch>"
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."