-2

I wanted to run git switch -c [new branch name].

Unfortunately, I have discovered that I'm using a version of git older than when that was added.

I'm worried I'll accidently lose my progress when switching to a new branch.

How would I do this switch when using an older version of git?

2
  • 3
    git checkout -b [new-branch-name]. Do not be worried about losing progress when switching branches. Commented Feb 14, 2024 at 20:56
  • 1
    Maybe the documentation for git switch is unclear? It’s an experimental which replaces some use-cases for git checkout. Commented Feb 15, 2024 at 10:58

1 Answer 1

-3

I think I figured it out

git stash
git checkout -b [new branch]
git stash pop
Sign up to request clarification or add additional context in comments.

2 Comments

There's no need for the stash
git checkout -b changes no files; it only makes a new branch label at the current HEAD. Any uncommited and/or staged changes stay exactly as they were

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.