1

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

videoguy
  • 1,732
  • 2
  • 24
  • 49
  • possible duplicate of http://stackoverflow.com/questions/9301782/need-to-reset-git-branch-to-origin-version – pratZ Aug 13 '14 at 19:55

2 Answers2

3

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

Stephan Rodemeier
  • 717
  • 10
  • 24
1

To get rid of all your local changes, use git reset

git reset --hard <branch-name> 

git reset --hard will get rid of changes in the working directory, index and also adjusts the head to the specified branch. So everything would look like the specified branch. Clean and neat.

In your case you can use:

git reset --hard vsg/p/androidopt
Stephan Rodemeier
  • 717
  • 10
  • 24
apadana
  • 13,456
  • 15
  • 82
  • 98