Open In App

How to Install and Use GIT in Android Studio?

Last Updated : 20 Jul, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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?

  • Free
  • Open Source
  • Super Fast
  • Scalable
  • Cheap Branching/Merging

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)

Select-windows-for-download

 

And the download should begin automatically.

Downloading-for-windows

 

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

Running-executable-file

 

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.

Selecting-destination-location

 

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

Selecting-default-settings

 

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

Completing-git-setup

 

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”.

Checking-android-studio

 

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.

Clicking-test-the-git-version

 

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

Building-repository-on-github

 

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

Clicking-enable-version-control-integration

 

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

Version-control

 

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

Git-repository-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”.

Choosing-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.

Adding-files

 

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

Adding-files-to-VCS

 

And then, all of the files should turn green.

Files-turned-green

 

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

Clicking-commit

 

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

Adding-comment

 

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”.

Clicking-push-option

 

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”.

Pasting-URL-of-repository

 

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

Clicking-push

 

Thus, we have uploaded a project to GitHub.

Uploaded-project-to-Github

 



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads