3

I'm on Windows using the latest git bash (git version 2.6.3.windows.1) and I'm trying to override my local repo. First I did:

git fetch /c/users/xxx/dropbox/repo/master

then I do

git reset --hard /c/users/xxx/dropbox/repo/master

but git comes back with:

fatal: Invalid object name 'C'.

What's the meaning of error message?

chhenning
  • 2,017
  • 3
  • 26
  • 44
  • Same message if you use /origin/master instead of origin/master. That obscure message needed some explanation. (what object is expected if you begin with "/"?) – pdem Sep 05 '17 at 07:57

1 Answers1

5

This is because the argument to reset is a "tree-ish", such as a branch name or a sha.

So, I think the commands you want are:

cd /c/users/xxx/dropbox/repo
git fetch
git reset --hard origin/master

Edit regarding your comment:

If you are interacting with a remote repo, your probably want to define a remote to it.

For example:

git remote add dropbox <dropbox url>

Then, the commands would change to:

git fetch dropbox
git reset --hard dropbox/master

You probably want dropbox/master rather than just master for your reset command because the fetch you just did would have updated your local dropbox/master branch pointer rather than your master branch pointer.

https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes

https://git-scm.com/docs/git-reset

Community
  • 1
  • 1
Jonathan.Brink
  • 23,757
  • 20
  • 73
  • 115
  • The dropbox is my remote repo. My current location is my local repo which is in a different folder. Does that change your answer? – chhenning Dec 10 '15 at 16:00
  • In short the answer is I need to use an alias to remote repo to use git reset --hard? – chhenning Dec 10 '15 at 16:05
  • @chhenning Basically, the reset command needs some sort of Git reference to change your HEAD pointer to. In your question you are passing in a file path which is confusing Git. Since you had just done a fetch, that implies you are downloading that latest content from the Git server, so whichever remote you have assigned to your dropbox repo (origin, or perhaps "dropbox" as my answer shows) you need to reference that ref with _remote_/_branchname_ – Jonathan.Brink Dec 10 '15 at 16:08