Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to discard all changes made to a branch?

Note: You CANNOT UNDO this.

Try git checkout -f this will discard any local changes which are not committed in ALL branches and master.


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


git diff master > branch.diff
git apply --reverse branch.diff

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