Git Worktree with Scaffold-Eth too

Versions

2023.09.10 - updated local repo setup to include a cd

Overview

this document will describe how to create a scaffold-eth 2 project with a remote fork and a local worktree

The following examples are based off the following forked se-2 repo:

Prerequisites

Remote Repository Setup (Github)

Fork Scaffold-Eth 2 Repo

  1. Navigate to se-2 repo

    https://github.com/scaffold-eth/scaffold-eth-2

  2. Click the Fork button to create a fork in [your-github]

  3. Name your [forked-repo]

 fork se-2 repository
fork se-2 repository
name new forked-repo
name new forked-repo

Local Repository Setup

  1. Create a local se-2 folder to contain projects

    example:

    PS C:\git> md se-2
    
  2. In se-2 Clone [your-github] [forked-repo] into a local main branch

    Navigate to the se-2 folder and clone your forked repo into a new main folder*./se-2>* git clone https://github.com/[your-github]/[forked-repo].git mainexample:

    PS C:\git\se-2> git clone https://github.com/OwlWilderness/se-2.git main
    
  3. In main Add Worktree for new Project Branch

    When creating a new project navigate to the main branch and execute the worktree add command. Specify a branch name and folder location. (the below example will put the folder in the same directory as main)

    example:

    PS C:\git\se-2\main> git worktree add -B project1 ../project1
    
  4. Change Directory to new Project

    PS cd ../project1
    
  5. Push to origin

    example:

    PS C:\git\se-2\project1> git push --set-upstream origin project1
    

Outcome

The folder structure should look like the following.

local folder structure
local folder structure

The contents of each folder should contain the scaffold-eth main project.

project folder contents
project folder contents

The remote git repository will contain the new branch.

git hub forked repo branches
git hub forked repo branches

Reference Articles

Subscribe to tekh
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.