You say Origin Master, I say Origin/Master.. let's call the whole thing off.

I had some old changes on one of my git branches today that I wanted to get rid of, they had been staged but I didn't need them. The easiest thing to do was just overwrite the local master branch with what is on the remote.

I tried the command: git reset --hard origin master

To which Git informed me -  fatal: Cannot do hard reset with paths

I figured out the problem was a missing / between origin and master, the actual command I needed was  git reset --hard origin/master which git was much happier with.

This did lead me to question, however, what the difference is between origin master and origin/master?

After some background reading I discovered this is actually 3 things.

origin, the remote repository name.

master, the remote branch name.

origin/master, the cached local copy of the the origin master remote branch.

So in typing: git reset --hard origin master I was incorrectly attempting to overwrite the remote master branch, hence the fatality :)

Using origin/master gets me back to my local branch and back to where I wanted to be with a direct replication of what was current on the origin master remote.

Clear as Mud....

3 comments:

  1. fado place items in the shopping ecommerce system of Amazon. Reputable service, fast, secure, is and has been widely used and very satisfied with our services.

    ReplyDelete
  2. Oh my gosh, thank you. Worked like a charm.

    ReplyDelete
  3. You have worked like a charm. You really have a spark in your self about software. I am damn dying on your idea's and you can take dissertation help online to get best instruction.

    ReplyDelete