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 onorigin
- if sha1 hash provided, reset done on corresponding commit.
what don't understand following values:
origin
head
origin/master
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 thinkorigin
self resolveorigin/head
think dependent on github settings, in github set 'default branch',origin/head
resolveorigin/[default_branch]
, in case im assuming it's master, why has same effectorigin/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 commitmaster
, localmaster
updated ,origin/master
updated too, if else pushesmaster
repo have no idea there update, unlessgit fetch
origin/master
move ahead ofmaster
, or maybe diverge.
runninggit reset --hard origin/master
have same effect if onmaster
branch ,master
in syncorigin/master
origin/branch
i'm not sure represents, because there's noorigin/branch
default, i'm guessing created branch calledbranch
, happens in same commit master, confirm can try doinggit branch
see branches, i'm guessing you'll find 1 calledbranch
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
Post a Comment