Skip to content

Quickly setup new branch

Peter Hjort Lauritzen edited this page Mar 14, 2025 · 2 revisions

Execute this script from where you want the new directory of branch to live

#!/bin/bash

# Ensure a branch name is provided
if [ "$#" -ne 1 ]; then
    echo "Usage: $0 <new-branch-name>"
    exit 1
fi

# Variables
GITHUB_USER="PeterHjortLauritzen"
CAM_FORK_URL="https://github.com/$GITHUB_USER/CAM.git"
UPSTREAM_REPO="https://github.com/ESCOMP/CAM.git"
BRANCH_NAME=$1
LOCAL_REPO_DIR="CAM"

# Step 1: Clone your fork if it doesn't exist
if [ ! -d "$BRANCH_NAME" ]; then
    echo "Cloning your personal CAM fork..."
    echo $CAM_FORK_URL
    git clone $CAM_FORK_URL $BRANCH_NAME
    cd $BRANCH_NAME || exit 1
    echo "Adding upstream repository..."
    git remote add ESCOMP $UPSTREAM_REPO
    git fetch --tags ESCOMP
    git branch $BRANCH_NAME ESCOMP/cam_development
    git checkout $BRANCH_NAME
    echo "Check out externals ..."
    bin/git-fleximod update
else
    cd $BRANCH_NAME || exit 1
    echo "Repository already exists, abort"
fi
Clone this wiki locally