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.

沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...