user1911091
user1911091

Reputation: 1373

Git: How to sync working directory with a specific commit of a branch

I have converted a whole svn repository to GIT following this

I have a full git repository with tags, branches and one master

(lets name the tags: tag1,tag2,tag3,... and the branches: branch1, branch2, branch3,...)

I now added files (lets name them: file1, file2, file3,...) and commited them to master (I see them in my working directory)

For the command :

git branch

the results are:

And if i do :

name@pc MINGW64 /path2GitRepo (master)
$ git checkout "svn/branch1"

the result is :

warning: refname 'svn/branch1' is ambiguous.
Switched to branch 'svn/branch1'
name@pc MINGW64 /path2GitRepo (svn/branch1)

But the files (file1, file2, file3,...) are still in my working directory. How is this possible, i have commited the files to master not to branch1?

What would be the command to bring my working directory into the state of a specific commit of a branch?

I even deleted everything (except the .git folder) from my working directory and did :

git checkout-index -f -a

but the files are still there.

Edit: Output of git show-ref:

2a1a9713eaedd9bc70f97568eae02752030515a9 refs/heads/master
8215eaf2d6049fc5f7375b0e7605af040860b4c8 refs/heads/svn/branch1
2a1a9713eaedd9bc70f97568eae02752030515a9 refs/heads/svn/branch2
a0886a261d934447ab089ad96a2838470176557c refs/heads/svn/branch3
fddda103d8fe4be3ba7cb929ec28cff0349b799d ...
8215eaf2d6049fc5f7375b0e7605af040860b4c8 refs/remotes/svn/branch1
a0886a261d934447ab089ad96a2838470176557c refs/remotes/svn/branch2
fddda103d8fe4be3ba7cb929ec28cff0349b799d refs/remotes/svn/branch3
2d3f16582b9bfba5ce491966624f31d59b417d03 ...
28fbcfcc64be5fcf0f7ea8e3e492ffee8a090e5c refs/tags/tag1
a68aeb93ea1a315323dc0ba2cd1d7d209469d33a refs/tags/tag2
56da5a8dcbef8b51ee748a2778e631e64ff69bda refs/tags/tag3
c3f879fdd5b401ced39135bd9d281d48f1dcc945 ...

Upvotes: 0

Views: 322

Answers (2)

Saurabh P Bhandari
Saurabh P Bhandari

Reputation: 6742

From the show-ref output, seems like your branch name is svn/branch1

Probably this should not show any warning :

git checkout "svn/branch1"

Upvotes: 0

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521514

Please remove the double quotes around the branch name:

git checkout branch1

I don't know if the double quotes are necessarily wrong, but typically if you wanted to checkout a branch name which requires escaping you would instead use:

git checkout -- branch1

Upvotes: 1

Related Questions