For as long as I used git, if I want to reset my local branch to the remote master branch, I've done
git reset --hard origin
and this seems to work empirically, but I recently learned that this might be dependent on the settings of the repository and origin may not always be the head of the remote master branch.
How can I check what its pointing to?
origin, by itself, typically refers to a specific remote - the one from which you cloned the repository. If you seeoriginas part of a longer string, likeorigin/mainororigin/develop, then it indicates that Git should check what it knows of a specified branch (in the examples,mainordevelop) as they are on theoriginremote.In the specific example you listed (
git reset --hard origin), your local branch will be reset to what Git knows of the associated remote branch. This is only possible because your local Git already knows that your current branch should track a specific remote branch. (Note thatgit resetdoes not initiate a network session of any kind, so if you haven't rungit fetchorgit pulllately then your reset may not match what's actually on the remote.)You can see what
originrefers to withgit remote -v(which will also list any other remotes) or withgit remote get-url origin(which will only list origin).