Need to reset git branch to origin version

前端 未结 5 1872
时光说笑
时光说笑 2020-12-04 04:34

I was accidentally working on a branch I shouldn\'t have been for a while, so I branched off of it giving it the appropriate name. Now I want to overwrite the branch I shou

5条回答
  •  被撕碎了的回忆
    2020-12-04 05:07

    There is a slightly easier way to do this:

    git reset --hard @{u}
    

    @{u} is a shortcut for whatever your tracking branch is, so if you're on master and that tracks origin/master, @{u} points to origin/master.

    The advantage of using this is that you don't have to remember (or type out) the full name of your tracking branch. You can also make an alias:

    git-reset-origin="git reset --hard @{u}"
    

    which will work regardless of the branch you're currently on.

提交回复
热议问题