Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to discard local changes in Android Studio GUI?

Tags:

git

android

I want to discard the local changes I made in an Android Studio project.

I tried to perform a pull, the GUI gives me 5 options, which option should I choose?

  • Octopus
  • Ours
  • Subtree
  • Recursive
  • Resolve
like image 686
ChiefAmay Avatar asked Dec 17 '25 21:12

ChiefAmay


2 Answers

In Android Studio do the following:

-Open the Version Control tool window Alt+9 and switch to the Log tab.

-Select the recent commit and right click on it than select Reset Current Branch to Here.

-A Git Reset popup will open -> select Hard -> click Reset

like image 97
Monika Moon Avatar answered Dec 20 '25 12:12

Monika Moon


You originally asked which strategy argument to use with git pull to discard your own work (there is a pending edit that will change the question, if the edit is approved). The answer is: None.

Don't use git pull at all. Run git fetch first:

git fetch origin

This brings over all the new stuff from the other Git you have your Git calling "origin".

Now that you have everything they have, simply stop using what you have been using, and switch to theirs:

git reset --hard origin/master   # assuming you're on your "master"

You may also want to use git clean -fdx to remove build artifacts, but that's a separate issue.

like image 27
torek Avatar answered Dec 20 '25 13:12

torek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!