Why does Git say my master branch is “already up to date” even though it is not?

前端 未结 7 1639
甜味超标
甜味超标 2021-01-29 17:17

Basic Problem

I just deleted ALL the code from a file in my project and committed the change to my local git (on purpose). I did

git pull upstream mas         


        
7条回答
  •  北恋
    北恋 (楼主)
    2021-01-29 17:56

    As the other posters say, pull merges changes from upstream into your repository. If you want to replace what is in your repository with what is in upstream, you have several options. Off the cuff, I'd go with

    git checkout HEAD^1  # Get off your repo's master.. doesn't matter where you go, so just go back one commit
    git branch -d master  # Delete your repo's master branch
    git checkout -t upstream/master  # Check out upstream's master into a local tracking branch of the same name
    

提交回复
热议问题