github - What's the difference between `git reset --hard master` and `git reset --hard origin/master`? -


i tried lot of links on stackoverflow/elsewhere understand behaviour of

git reset --hard option

i know that:

  • if omitted or if origin, reset done on recent commit on origin
  • if sha1 hash provided, reset done on corresponding commit.

what don't understand following values:

  1. origin
  2. head
  3. origin/master
  4. origin/branch

all seem have same behavior i.e. point latest commit on master.

please explain significance of 4 value option provided above.

i know if on specific branch how can reset last commit on branch? if example on v1.2, origin/v1.2 still takes me latest commit on master.

first of need understand branch , tag names pointers hash values, represent single commit, if there's 4 options have same behaviour, first logical answer because point same commit

  • origin i'm not sure think origin self resolve origin/head think dependent on github settings, in github set 'default branch', origin/head resolve origin/[default_branch], in case im assuming it's master, why has same effect origin/master.

  • head points current commit, 1 standing on, git reset --hard head permenantly remove changes in tracked files , staged files changes, not change commit hash.

  • origin/master last commit in remote master branch since last fetch/pull, each time commit master, local master updated , origin/master updated too, if else pushes master repo have no idea there update, unless git fetch origin/master move ahead of master, or maybe diverge.
    running git reset --hard origin/master have same effect if on master branch , master in sync origin/master

  • origin/branch i'm not sure represents, because there's no origin/branch default, i'm guessing created branch called branch , happens in same commit master, confirm can try doing git branch see branches, i'm guessing you'll find 1 called branch

to see in visual way, try running git log --graph --decorate --all or prefer visual tool gitk, if have binary installed run gitk --all see branches relative each other


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -