I can not switch to a branch in Android Studio. I try to make commit and push (+ pull done) through VCS, it gives something like this:

enter image description here

Or if, when going under the studio in VCS -> Git -> Branches, I try to switch to the Vadim branch, there is no checkout command, although it should be in theory.

enter image description here

git status shows the following

Sashas-iMac:999_app_android vadim$ git status On branch master Untracked files: (use "git add <file>..." to include in what will be committed) .DS_Store .gradle/ .idea/ 999.iml 999_app_android.iml _999/.DS_Store _999/gradle/.DS_Store _999/libs/.DS_Store _999/src/.DS_Store _999/src/main/.DS_Store _999/src/main/java/.DS_Store _999/src/main/java/md/.DS_Store _999/src/main/java/md/simpals/.DS_Store _999/src/main/java/md/simpals/md999/.DS_Store _999/src/main/java/md/simpals/md999/activities/.DS_Store _999/src/main/java/md/simpals/md999/adapter/.DS_Store _999/src/main/java/md/simpals/md999/adapter/formAddAds/.DS_Store _999/src/main/java/md/simpals/md999/fragments/.DS_Store _999/src/main/java/md/simpals/md999/rest/.DS_Store _999/src/main/java/md/simpals/md999/views/.DS_Store _999/src/main/res/.DS_Store _999/src/main/res/drawable-hdpi/.DS_Store _999/src/main/res/drawable-mdpi/.DS_Store _999/src/main/res/drawable-xhdpi/.DS_Store _999/src/main/res/drawable-xxhdpi/.DS_Store _999/src/main/res/drawable-xxxhdpi/.DS_Store _999/src/main/res/drawable/.DS_Store _999/src/main/res/layout-large/.DS_Store _999/src/main/res/layout/.DS_Store _999/src/main/res/values-ro/.DS_Store _999/src/main/res/values/.DS_Store build.gradle build/ gradle/ gradlew gradlew.bat local.properties settings.gradle nothing added to commit but untracked files present (use "git add" to track) 

Note: This project installed from the archive.

  • find the file that is described in the error and delete it, as stated in the error - Vladyslav Matviienko
  • What does git status say? - Sanek Zhitnik
  • The @metalurgus file has been deleted, but on another attempt to push, it produces the error "Push rejected", Push to Vadim / master was rejected. - Morozov
  • And then there must be the cause of the reject. Or you just have to do the pool first - Vladyslav Matviienko
  • @metalurgus corrected the question, the problem did not dare. - Morozov

1 answer 1

You have written there: Pull failed. Pull failed because he suggests changes to the files that you have also changed. It is not clear what should be with the changes after the pull. Even the list is given from five files blocking the pool.

Push does not work because your history of the master branch differs from the history of the master branch on the remote server, i.e. origin/master .

I can not switch to a branch in Android Studio

None of the actions that you described should lead to a switch to a branch. What happens when git checkout Vadim ?

If you switch, the problem seems to be solved and you can commit there.

If not, then the changes made are in conflict with this thread. What can be done to fix it:

  1. First, get the .gitignore file and add trash to it, like .DS_Store
  2. Create a new branch: git branch backup
  3. Save all necessary changes to commit. At least those that conflict.
  4. Switch to master . Pull changes from remote server.

     git checkout master git fetch 
  5. Now you need to decide whether you can commit directly to master ? If so , try this:

     git pull --rebase 

    At the same time, commits from the remote/master branch will be pulled up in an unchanged form and order into your branch, and your own commits will stand up after them.

    If not, then you need to return the master to the state that is on the remote server.

     git checkout master git reset --hard origin/master 
  6. Now you have:

    • In the master branch, the fact that all
    • All changes are saved.
    • You can switch to your branch.
  • And what action? delete these 5 files chtoli? .. Tried to create a new branch, also fails. - Morozov
  • @VadimMorozov supplemented the answer - Nick Volynkin
  • @VadimMorozov exactly how you tried to create a new branch, that you did not succeed? - Nick Volynkin
  • I managed to create / delete a branch, now I will try the above steps. git checkout Vadim does not work - again, these 5 files pop up. - Morozov
  • git reset --hard origin / master fatal: ambiguous argument Use '-' to separate paths from revisions, like this: 'git <command> [<revision> ...] - [<file> ...]' - Morozov