Hello, I'm still new to mastering GIT for version control.

According to the manual (Android Studio Git) I understood how to create a repository (in Android Studio) of the project and add my projects there. However, I have some difficulties:

When the project was added to the repository, all the files on the left were colored green. But now when I make a change to one of the java files. For example, add another field to the class. This java file is supposed to turn blue because new changes have occurred and you need to save these changes in Git. But he does not, the java file remains colored green. Is this a problem with Android Studio or did I set something up like that?

Thanks in advance for the great replies.

  • one
    I think in AS there are no such tools to clone repositories. And it is easier to use git itself, since these are its affairs, and not IDE (the studio is not a version control system, but only uses it). Git even has some Git GUI when it is installed on a computer, so that no long commands can be typed in the console. - pavlofff
  • and you made the added files? - ivan K.
  • @pavlofff, thanks a lot for the answer. Actually, everything that I wrote in my question I learned to do in the program sourceTree , it seemed to me easier and clearer to master. Simply, my colleagues told me that the built-in development environment (in Android Studio, for example) will work better and more correctly use the development environment directly for version control, and not a third-party program (they really did not work in this environment). So I tried to master git in Android Studio. - foxis
  • @ivanK. Yes, I did. Anyway, the class file on the left is colored green. Now I specially repeated the procedure. Those. zakomitil, then added a new field to the class. Result: no change class remained green. - foxis
  • one
    I've looked at myself. If only local Git is connected, then the files do not turn blue with changes, however, in VCS -> Local History -> Show History it is shown that there were changes. When kommite these files are proposed for transfer. If a remote repository is connected to the local Git (for example, GitHub), then it becomes blue when editing. Maybe it should be. - pavlofff

1 answer 1

Answer the first question:
IntelliJ's development environments use the following color scheme:

  • White - tracked files that have not changed since the last commit
  • Blue - tracked files that have been modified since the last commit. Regardless of whether they were indexed or not.
  • Green — Untracked files that have been indexed (git add). Including if they have changed since the moment of indexation.
  • Red - untraceable files that have not been indexed.
  • Gray - ignored files

enter image description here

As you can see, the development environment does not distinguish between two states:

  • The file was indexed and did not change after that.
  • The file has been indexed and changed after

These states are well distinguished in the console:

➜ git-coloring-example git:(master) ✗ git status -s M tracked-and-changed.py A untracked-and-indexed.py ?? .idea/ ?? untracked-and-not-indexed.py 

The first character indicates the status of the file in the index, the second - in the workspace. Here we indexed the first file:

 ➜ git-coloring-example git:(master) ✗ git add tracked-and-changed.py ➜ git-coloring-example git:(master) ✗ git status -s M tracked-and-changed.py A untracked-and-indexed.py ?? .idea/ ?? untracked-and-not-indexed.py 

And now we will change the second

 ➜ git-coloring-example git:(master) ✗ echo change > untracked-and-indexed.py ➜ git-coloring-example git:(master) ✗ git status -s M tracked-and-changed.py AM untracked-and-indexed.py ?? .idea/ ?? untracked-and-not-indexed.py 
  • @ NickVolynkin, thanks a lot for the answer. It turns out that I have just the case in which the file is indexed, but has already managed to change. Therefore, the color is not fixed. Is it possible to index through Android Studio without using the command line? - foxis
  • one
    @foxis is possible, there is a hot key (probably it depends on the OS) and through the context menu. But I strongly recommend that you master the command line too. Better when there is a choice than when there is none) - Nick Volynkin
  • @foxis yes, you got a question of two questions here. On Stack Overflow, in Russian, it is customary to formulate atomic questions, so more order is sought and better searched. Once I answered the first one - could you take the second one to a new question? On it, either I will answer or someone else. - Nick Volynkin
  • one
    About the addition: here's a ready answer. An example is now inconvenient to bring, I am writing from the phone. ru.stackoverflow.com/q/431839/181472 - Nick Volynkin
  • one
    @foxis please. And as a thank you, you can add something;) - Nick Volynkin