2017年11月6日 星期一

[ Git 常見問題 ] How to undo a git pull?

Source From Here 
Question 
I would like to undo my git pull on account of unwanted commits on the remote origin, but I don't know to which revision I have to reset back to. 

How can I just go back to the state before I did the git pull on the remote origin? 

How-To 
Use git reset command: 
// --keep
// Resets index entries and updates files in the working tree that are different between and HEAD. If a file that is different between and HEAD has local changes, reset is aborted.
// --hard
// Resets the index and working tree. Any changes to tracked files in the working tree since are discarded. 

# git reset --keep HEAD@{1}

Versions of git older than 1.7.1 do not have --keep. If you use such version, you could use --hard - but that is a dangerous operation because it loses any local changes.

沒有留言:

張貼留言

[ Py DS ] Ch1 - IPython: Beyond Normal Python

Source From  Here   Keyboard Shortcuts in the IPython Shell   If you spend any amount of time on the computer, you’ve probably found a u...