Copying a git branch from one machine to another
Sun 08 February 2026

I often bounce between two Macs when I work. I use a Mac mini with a Studio Display set up in my office, which I use as my main workstation. I also have a MacBook Air that I use when traveling and also when I feel like doing a little work in a new setting in my house.

Sometimes I’ll be in the middle of implementing a new feature or refactoring code on a project and I want to continue it on the other machine without pushing incomplete changes through GitHub.

There are a few ways to solve this, but these are the steps I follow and have worked well for me.

  • On the machine where the branch already exists (e.g. my laptop called m3air): make sure the changes have been committed locally to the branch.

  • On the machine where you want to continue the work (e.g. my desktop called mini): add a remote reference:

    git remote add m3air m3air:/path/to/repo/on/m3air

  • Fetch just that branch:

    git fetch m3air the-branch-name

  • Create a local branch from it:

    git switch -c the-branch-name m3air/the-branch-name

  • (Optional) Remove the remote reference if it’s no longer needed (but I keep the reference so next time there is one less step required):

    git remote remove m3air

Then you can continue working on the new branch and push it as a new PR or merge it locally.

Once merged, you can pull main to the original machine (m3air in my example) and delete the old branch as the changes are already merged in.