How to discard all changes made to a branch?

后端 未结 9 1298
粉色の甜心
粉色の甜心 2021-01-29 18:03

I\'m working in a branch (i.e. design) and I\'ve made a number of changes, but I need to discard them all and reset it to match the repository version. I thought

相关标签:
9条回答
  • 2021-01-29 18:57

    git reset --hard can help you if you want to throw away everything since your last commit

    0 讨论(0)
  • 2021-01-29 19:02

    If you don't want any changes in design and definitely want it to just match a remote's branch, you can also just delete the branch and recreate it:

    # Switch to some branch other than design
    $ git br -D design
    $ git co -b design origin/design            # Will set up design to track origin's design branch
    
    0 讨论(0)
  • 2021-01-29 19:02

    git checkout -f

    This is suffice for your question. Only thing is, once its done, its done. There is no undo.

    0 讨论(0)
提交回复
热议问题