version control - What is the meaning of git reset --hard origin/master?

ID : 10122

viewed : 34

Tags : gitversion-controlgit-resetgit

Top 5 Answer for version control - What is the meaning of git reset --hard origin/master?

vote vote

95

git reset --hard origin/master 

says: throw away all my staged and unstaged changes, forget everything on my current local branch and make it exactly the same as origin/master.

You probably wanted to ask this before you ran the command. The destructive nature is hinted at by using the same words as in "hard reset".

vote vote

88

In newer version of git (2.23+) you can use:

git switch -C master origin/master 

-C is same as --force-create. Related Reference Docs

vote vote

70

vote vote

66

To add to the great suggestions already here, XIP.IO is a fantastic wildcard DNS server that's publicly available.

      myproject.127.0.0.1.xip.io  -- resolves to -->   127.0.0.1   other.project.127.0.0.1.xip.io  -- resolves to -->   127.0.0.1    other.machine.10.0.0.1.xip.io  -- resolves to -->   10.0.0.1 

(The ability to specify non-loopback addresses is fantastic for testing sites on iOS devices where you cannot access a hosts file.)

If you combine this with some of the Apache configuration mentioned in other answers, you can potentially add VirtualHosts with zero setup.

vote vote

52

Editing the hosts file is less of a pain when you run "ipconfig /flushdns" from the windows command prompt, instead of restarting your computer.

Top 3 video Explaining version control - What is the meaning of git reset --hard origin/master?

Related QUESTION?