Search code examples
gitgit-branchgit-reset

How do I revert changes in local git branch to remote tracking branch?


I know enough of git to be dangerous. I am working on frameworks/base git of android repo. I changed to a branch p/androidopt. This branch has remote tracking branch vsg/p/androidopt.

Later I made changes and commited them to local branch. I have around 17 of them. I didn't push these changes to remote tracking branch. They are available only in my local branch.

Now I want to reset my local branch to remote tracking branch (i.e vsg/p/androidopt) ignoring all the changes in the local branch.

Can someone provide a git command to do this using the above branch names?

Thanks


Solution

  • 1. option: delete the branch and recreate

    git branch -D p/androidopt

    and then to do this

    git checkout -b p/androidopt --track vsg/p/androidopt/

    Make sure to use the right branch names though.

    2. option: reset

    git reset --hard vsg/p/androidopt