Amadeu Cabanilles Amadeu Cabanilles - 15 days ago 4x
Git Question

GIT: create and get Branch from a previous commit

I've just created a branch from a previous commit with the command

git branch thenewbranch 03771674c482e4611cc48ee120a16a91dfb2793d

Now I want to checkout the branch to work with in Eclipse with

$ git checkout -b thenewbranch

But i got this error

fatal: A branch named 'thenewbranch' already exists.

git checkout -b thenewbranch

means create a new branch called "thenewbranch" and then go into it

you only need to

git checkout thenewbranch

git checkout -b|-B [] Specifying -b causes a new branch to be created as if git-branch[1] were called and then checked out. In this case you can use the --track or --no-track options, which will be passed to git branch. As a convenience, --track without -b implies branch creation; see the description of --track below.

If -B is given, is created if it doesn’t exist; otherwise, it is reset. This is the transactional equivalent of