videoguy
videoguy

Reputation: 1918

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

Upvotes: 1

Views: 358

Answers (2)

apadana
apadana

Reputation: 14690

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

Upvotes: 1

Stephan Rodemeier
Stephan Rodemeier

Reputation: 717

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

Upvotes: 3

Related Questions