dragonmnl
dragonmnl

Reputation: 15558

Git: how to switch from branch X to Y?

For example, I clone step_06 of:

git clone -b step_06 https://github.com/Urigo/meteor-angular-socially

Now I want to replace step06's files with step07's files (on my machine). So I did:

git checkout -b step_07

cd meteor-angular-socially

git checkout -b step07

Switched to a new branch 'step_07'

However nothing actually changes in the folder/files.

What am I doing wrong?

Upvotes: 0

Views: 192

Answers (1)

VonC
VonC

Reputation: 1328212

You are creating a new local branch instead of switching to the one from the remote repo.

git checkout step_07 should have been enough (from man git checkout):

If <branch> is not found but there does exist a tracking branch in exactly one remote (call it <remote>) with a matching name, treat as equivalent to:

git checkout -b <branch> --track <remote>/<branch>

Make sure to do a git fetch first, in order to get all remote branches.

But in your case, add git reset --hard origin/step_07

Here are the differences between step_06 and step_07, as reported by GitHub.

Upvotes: 2

Related Questions