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.

沒有留言:

張貼留言

[Linux 文章收集] Linux / Unix: Check Last Time User Logged In On The System

Source From  Here   Question   I am a new Unix system admin. How do I find ouw who has recently use the Linux or Unix-like server?  Which te...