Git pull deleted uncommitted changes

前端 未结 5 1876
有刺的猬
有刺的猬 2020-12-03 18:29

I just made a new repository on github. Starting with a folder full of files, the steps I did were:

git init
git add -A
git remote add origin ...

#Now pull          


        
5条回答
  •  再見小時候
    2020-12-03 19:11

    I did the similar thing When I was trying to push my commit and was getting hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again.

    I tried to revert my commits by

    git reset HEAD~3 . 
    git stash 
    git pull 
    git stash pop
    git push
    

    and accidentally pulled again and push the changes. All my work for 7 days was lost.

    This worked for me to get all of my work back in local branch:

    git reset --hard HEAD@{"15 minutes ago"}

提交回复
热议问题