Rollback last "git pull upstream" (conflict occurs) into the old state -
i did update file , committed changes (efe5e5d (head, master) change caption
), fired git pull upstream
while upstream's code changed recently, of course caused me conflict.
git show-ref
efe5e5d65603419288e40b8e964aecba4626c99f refs/heads/master 879020dbcd1cf1f797577b66a9416c1007a1ad29 refs/remotes/upstream/head 20e54d8ccaa4dba7890fa5db2e89394ab33a0c81 refs/remotes/upstream/dev 879020dbcd1cf1f797577b66a9416c1007a1ad29 refs/remotes/upstream/master
the conflicted file (index.html)
<<<<<<< head <a href="about.html" class="btn btn-success">goto about</a> ======= <a href="about.html" class="btn btn-success">about page</a> >>>>>>> 879020dbcd1cf1f797577b66a9416c1007a1ad29
git status
your branch , 'upstream/master' have diverged, , have 1 , 1 different commit each, respectively. (use "git pull" merge remote branch yours) have unmerged paths. (fix conflicts , run "git commit") unmerged paths: (use "git add <file>..." mark resolution) both modified: index.html
git log
* efe5e5d f72465f (head, master) change caption * f72465f 28645ce add link button * 28645ce 48c2640 20e54d8 merge branch dev'
question how rollback last git pull upstream
old state?
the purpose of learn, it's not real code. think cannot use git reset
, think following related.
git update-ref refs/remotes/upstream/master refs/remotes/upstream/master@{1}
git checkout -- index.html
(i'm not sure because git status suggest this)- what should
refs/remotes/upstream/head
?
please guide thanks.
edited
i think have found solution problem.
git merge --abort
git update-ref refs/remotes/upstream/master refs/remotes/upstream/master@{1}
with these 2 commands, can fire git pull upstream
again never happenned before.
while doing git pull
, tracking branch updated , merge performed between remote branch , local branch. if conflict occurs, merge stops in between allowing resolve them , git commit
. have @ this:
you have unmerged paths. (fix conflicts , run "git commit")
the merge finishes after git commit
. so, return state branch before git pull upstream
, you'll have hard reset since changes still unmerged.
git reset --hard
it remove staged changes. remove conflicted files also(which unstaged), following.
git add index.html git reset --hard
Comments
Post a Comment