Git for Android Developers(Part 2) — List of operations

Rajkumar Srinivasan
IVYMobility TechBytes
4 min readNov 25, 2018

This tutorial is a continuation of Part 1 of the series. So i would recommend checking out Part 1 first.

In the first part we learned about version control system. Now im straightly jumping into the list of GIT operations assuming that you have enabled VCS integration and added your project in GIT. Once the VCS is enabled, you can able to see the Git option in VCS window like below.

Let’s explore the options under GIT.

Green- File operations, Red- Repo operations

We can differentiate the options as,

  1. File operations(Green Color Box)
  2. Repository operations(Red Color Box)

File operations

commit File- To commit the selected file.

Add(Ctrl+Alt+A) - To add the selected file to GIT.

Annotate- To show last modified information for every line in a selected file.

Show Current Revision- To show current(last commit) revision number.

Compare with same repository version- To compare the local changes of selected file with latest committed revision.

Compare with…- To compare the local changes of selected file with the selected revision.

Compare with Branch…- To compare the selected file with the other available branches in the repository.

Show History- To show the history of the selected file.

Show History for Selection- To show the history of the selected lines in a file.

Revert(Ctrl+Alt+Z) - To revert the local changes made in the selected file.

Resolve Conflicts…- To resolve conflicts available while merging the changes.

Repository Operations

Branches- To show the list of available branches

Tag- To create a tag or unique identifier for a commit.

GIT already providing SHA key for every commit as a unique identifier but the difference is you can create your own tag with name and discription. You can provide the relase details or any information in the description so that it will be easy to identify. Also you can search the commit using tag name from version control window.

Merge changes- To merge the selected branch to the current branch.

Stash Changes- To store the local changes in a separate file.

Consider you’re working on a module and you have written a lot of code for adding a new feature which is not commited. Now you want to take a build without the current changes, then you can simply stash those changes and take build. After that you can un stash it and continue your work.

Un Stash Changes- To restore the local changes from stash file to work space.

The changes you stashed will come to your workspace as local changes, then you can continue your work from where you stopped.

Reset Head- To reset to the selected revision. There are three types of reset available, we can use it based on our need..

  • Soft- Index and working tree changes will be same as the HEAD.
  • Mixed- Index will be reset to the selected version but working tree changes remains the same as HEAD.
  • Hard- Index and working tree changes will be reset to the selected revision.

Remotes- To show the list of GIT remote URLs .

Clone- To clone/checkout repository from the given repository URL.

Fetch- To fetch the updates from remote repository.

Pull- The action of fetching and merging the selected branch in one shot.

Push(Ctrl+Shift+K)- To push the committed changes to the server.

Rebase- As like merge, it is used to integrate the changes of one branch to another branch but in different ways. Rebasing the branch to the tip of another branch as a new commit.

Adv: History will be linear

Dis Adv: We lose the traceability. Rebasing loses the context provided by the merge commit.

Hope you got an idea about the options under GIT in Android studio IDE. In the next part, I will show you the list of operations we can do in the version control window.

Next Part,

Thanks for reading.

--

--

Rajkumar Srinivasan
IVYMobility TechBytes

Android Apps Developer - Passionate about mobile development and learning.