Git for Android Developers - Part1

What is Git?

Git is an open-source version control system that helps to back up your code and keeps track of all the changes done on a particular file. The files will later be pushed to the online repository GitHub, which enables better collaboration when multiple developers are working on a single project.

How to set up Git for Android Studio?

Download Git from its official website and install it on your system. Open Android Studio File->Settings->Version Control->Git, ideally Android Studio should detect the path to the git executable, if not search for the file. If you click on the Test button at the top right corner, it will show the Git-installed version.

Create an account in GitHub.

Go to Android Studio File->Settings->Version Control->GitHub and add your account.

How to use it?

Let us understand the basic steps of moving files to github from android studio.

First, create a repository in github where you want to store your documents/software files.

In android studio, go to VCS tab and enable version control integration to Git tool.

you can see that all the files which are not added to Git staging area are in red color.

right click on the files/folder-->Git-->Click on Add command, now the files are added to Git and color changed to green.

Share your files to Github repository. Navigate to Git->Github->Share project on Github. Provide a description and click on share. Provide commit message and click on Ok. Once the files are moved you get a message at the below right corner of your Android studio.

You can see the files added to github repository.

Now that your project is in version control(git), you can make further changes and commit and push them to github after every change, or you can even club multiple changes together and push it to github.

Here I made one change to one of my files util.kt and it turned to blue color because the changes doesn't match with the version control file.

Let us commit and push it to Github.

New changes are now pushed to github repository.

Conclusion

Git is a powerful tool which is widely used by developers across the world. In this article we have covered very basic things about git. It has vast features and we will try to explore them in the upcoming articles.