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

前端 未结 7 1583
甜味超标
甜味超标 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 18:00

    Any changes you commit, like deleting all your project files, will still be in place after a pull. All a pull does is merge the latest changes from somewhere else into your own branch, and if your branch has deleted everything, then at best you'll get merge conflicts when upstream changes affect files you've deleted. So, in short, yes everything is up to date.

    If you describe what outcome you'd like to have instead of "all files deleted", maybe someone can suggest an appropriate course of action.

    Update:

    GET THE MOST RECENT OF THE CODE ON MY SYSTEM

    What you don't seem to understand is that you already have the most recent code, which is yours. If what you really want is to see the most recent of someone else's work that's on the master branch, just do:

    git fetch upstream
    git checkout upstream/master
    

    Note that this won't leave you in a position to immediately (re)start your own work. If you need to know how to undo something you've done or otherwise revert changes you or someone else have made, then please provide details. Also, consider reading up on what version control is for, since you seem to misunderstand its basic purpose.

提交回复
热议问题