I wrote the program and at one certain point I suddenly Android Studio stopped recognizing the path to the resources "import example.R;".

I tried to remove the changes I made before the last commit, but this infinite indexing did not stop ...

I decided to go back to the last commit, poked a lot of things in the VCS tab, but didn’t figure out how to do it (before going into VCS, I copied the whole project just in case).

Please tell me how via Android Studio to return my entire project to the last commit in git? For the whole project to return to that mind when I made this last commit.

    3 answers 3

    Decision:

    I see in the question that you did not commit, if you also did not add the modified files to the index with the git add command, you can use the command:

     git checkout -- . 

    This command rolls back the modified files to their original state, i.e. when there was absolutely no change.

    Theory:

    Where does Git find out which branch you're on at the moment? It stores a special pointer called HEAD.

    • git reset - updates the index by moving it to HEAD.

    • git checkout - updates the work branch. HEAD will be updated in case you make the transition from branch to branch.

    The main thing:

    You need to understand what you want to receive after entering the command. Described in more detail here - link to the article .

    • Yes, I did not commit, and git add too. And where do you need to register this command? I just never used them, I do everything through the Android Studio interface. - Dmitry Chubarov
    • "git checkout -." - used? - Timur Mukhortov
    • No, I want to try to use it, but I do not know where to write this command. - Dmitry Chubarov
    • If you are working in Android Studio below there is a Terminal tab. - Timur Mukhortov
    • Yes, there is now registered "git checkout -." but nothing happened - Dmitry Chubarov

    git checkout -. (prescribe this command in the Terminal and rollback to the last commit will occur) The problem with resources was solved by "Build -> Clean Project", after that R became visible.

    • It was not necessary to go back to the last commit to solve the problem with resources. It can occur out of the blue even without changing the code. - Enikeyschik
    • Yes, I already understood it. I just thought that I had inadvertently done something and it would be better to return to the last commit, since I can do what I did after the commit. But the next time, of course, I’ll first do "Build -> Clean Project" - Dmitry Chubarov

    Down in the speaker there is a Version Control window. It has a Log tab. All commits are there. Select the desired mouse, right button - Reset. Different options will be offered. If you just need to return to the previous commit without saving changes, then select Hard.

    enter image description here (picture from the Internet)

    This means Android Studio. If you do it via the git итд command line, and git итд , then the speaker is not needed for this, and you can do it in a regular console.