Open In App

How to Install and Use GIT in Android Studio?

Git is created by Linus Torvald. Git is the most popular Version Control System in the world, used by millions of developers. It helps us to keep track of all the files in a project. Git tracks every change that are made. If we make a mistake, it can reset a file to match a previous version or we can also reset the version of all the project files at the same time. The collection of all versions of the project files is known as a Git Repository. It’s basically a folder in which we can edit our files and then run Git commands to store the changes made and pull in changes from other contributors. We can have multiple Git repositories on our computer one for each project we are working on. 

Why Git?



Android Studio

Android Studio is the official IDE (Integrated Development Environment) for Android app development. It is based on JetBrains’ IntelliJ IDEA. 

Installing Git in Android Studio

To get started we have to install Git which can be downloaded from the official website git-scm.com/downloads



Step 1: On the download, section select the operating system that we are working on. (As I am working on Windows so, I am going to select Windows)

 

And the download should begin automatically.

 

Step 2: Once the download is done we are going to run the executable and then hit “Yes” and then click “Next”.

 

Now, setting up the path is a very important process. It is highly recommended to keep it as the default path because Android Studio can auto-detect Git.

 

Then keep on hitting next by keeping everything as default. And then finally we have to click install.

 

And then click on finish, and Git should be installed on the computer.

 

Step 3: Now let’s check on Android Studio whether it auto detects where Git was downloaded. So, to do this we are going to click on “File” and then on “Settings”.

 

Now, in Settings, we are going to click on “Version Control” and then “Git”, and in the top portion, it is said that “Auto Detected” is the path where the Git executable file is, and on clicking on “Test” the Git Version which is installed is shown.

 

Step 4: To install Git in Android Studio, we have to build a repository on GitHub first.

 

Step 5: Now coming back to Android Studio, click on “VCS” (Version Control Systems) and then click on “Enable Version Control Integration”. 

 

Step 6: Then on selecting a version control, click “Git” and then “Ok”.

 

Step 7: Now, it is shown that a Git repository is created.

 

Don’t worry if all the files turn red. It is because we haven’t uploaded those files to GitHub yet.

Step 8: In the next step, now coming over to the far left instead of having “Android” we are going to choose “Project”.

 

And then we are going to right-click on the first folder coming down to Git and then we are going to add those files.

 

So, it’s going to add them all to our Version Control System.

 

And then, all of the files should turn green.

 

Step 9: Coming over to Git and then clicking on “Commit”.

 

It will ask us to add a comment to it and then click on “Commit”.

 

Do not worry about the warnings that are shown. Only the code should not contain any errors, and thus, Git is installed in Android Studio, and also we learned how to commit the files using Git from Android Studio. Now, if we want, then, we can “Push” the files to the GitHub

Step 10: Come over to Git and then click on “Push”.

 

Now, we need to “Define remote” which is actually the repository to which we are uploading to, and then we need to copy and paste the URL of the repository and then click “Ok”.

 

We are shown a list of files that were added to the repository. Now, all we have to do is click “Push”.

 

Thus, we have uploaded a project to GitHub.

 


Article Tags :