paint-brush
The Most Useful Git Commands for Junior Android Developersby@anaumova
645 reads
645 reads

The Most Useful Git Commands for Junior Android Developers

by Anna NaumovaJuly 5th, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Anna Naumova is an Android Developer with several years of experience. In this article she says in general about Git - a distributed version control system and its most useful commands that she uses in her daily work. She also explains why a Junior Android developer needs to master these commands even before he gets his first job

People Mentioned

Mention Thumbnail
featured image - The Most Useful Git Commands for Junior Android Developers
Anna Naumova HackerNoon profile picture

Hello, community!


I’m Anna Naumova, and I’m really passionate about Android Development.


Currently, I work in a company that develops a mobile app - a messenger with audio and video calling functions, and I’m actively involved in the development of many useful app features. In this article, I’d like to tell you in general about Git - a distributed version control system and its most useful commands that I use in my daily work. I’d like also to explain why a Junior Android developer needs to master these commands even before he gets his first job. I will also talk in general about how a workflow is usually arranged in most companies. Perhaps this article will be helpful to Junior Android Developers who are in the early stage of their career.


Now, looking back, I can say with confidence that if I had mastered Git earlier, my adaptation to the company would have happened much faster. When I learned how to use Git competently, the quality and speed of my work increased significantly.



The reason for publishing this article was my daily observations over several years. Talking to Junior Android Developers who are just looking for their first job, I’ve noticed that they often underestimate the importance of the Git tool. Preparing for their job interviews, they often carefully study fundamental concepts (SOLID, principles of object-oriented programming, data structures), mobile development technologies (working with a network, databases, multithreading, etc.), prepare detailed answers to common interview questions, learn the algorithm complexity, but at the same time they usually have absolutely no idea about the workflow. To my way of thinking, this approach is wrong. Once a candidate accepts a job offer, he becomes a member of a team, and every team has its own specifics and rules to follow, and Git is an important tool for organizing code work in a team.


First of all, one should note here that I am in no way detracting from the importance of knowing the fundamental concepts of programming. In my opinion, understanding these concepts is a very important skill for being a successful Android Developer. This is a base, a skeleton, on which all further study of the remaining programming skills is built. In my opinion, that’s why questions about the basic principles of object-oriented programming are very often asked at job interviews. If a candidate understands the basic principles of programming well, then no doubt it is much easier for him to switch to a new technological stack. However, it is equally important, in my opinion, to understand a company workflow when many distributed teams work on one product and write a lot of code. For most cases, knowing a few basic console commands and hotkey combinations will come in handy. I have been using these commands and hotkeys every day in my work for several years, and it makes my work convenient and saves a lot of time.


It should be noted that at the initial stage of a career in mobile development, a Junior Android Developer should not study Git deeply. In my opinion, it is much more useful to understand the main principle of how Git works than to learn a lot of complex commands. For most daily tasks, knowing a few basic console commands and hotkey combinations is enough. Even now, after several years, I have been using these commands and hotkeys every day in my work for several years now, and it makes my job convenient and saves a lot of time.


The Git system can be loosely compared to a tree. This tree stores the entire commit history.

There is the main trunk of the tree - this is a branch with the actual code, which is usually called "master." This branch contains the overall result of the team's work. Below you can see a good visualized example:


Git Command Visualized (original https://www.dolthub.com/blog/2022-12-14-wordcels-guide-to-git/)



Usually, working with the project code in a distributed team according to the following scheme:


A developer gets a task (where he should implement a certain feature, fix a bug, etc.)., which is assigned a number. Execution of all project tasks is tracked in a project management tool (for example, Jira). Until the developer has taken the task to work, it hangs in the "ready for development" status. As soon as the developer takes the task to work, it goes into the "in work" status.


The developer will perform this task in a separate git branch, which needs to be started from the master branch. To do this, you can open a terminal in Android Studio and run the following git commands:


  • Git checkout master - switch to the master branch

  • Git pull - "pull" the current code from the master branch, which is located on the remote repository.

  • Git checkout -b “your new branch name” (create a new branch and switch to it immediately). Note that, usually, the branch number corresponds to the issue number.

  • Git status to make sure you're on the branch you expect.


Let's say that you completed a task and want to push your changes to a remote repository for review. To do this, you can run the following commands (in the Android Studio Terminal or using keyboard shortcuts):


  • Ctrl+A+L ​​- Format code so it looks nice and is easy to read for other developers
  • Ctrl + A (highlight code)
  • Ctrl+Shift+A (or "git add" in the terminal). This command will add your code to Git
  • Ctrl + K (or "git commit" in the terminal). This command will commit the changes in the code. Don’t forget to write your commit message.
  • Ctrl + Shift + K (or "git push" in the terminal). This command will push your changes to the remote repository. After that, the Android Developer can change the task status from “in work” to “in review.”


A tip: before I commit and push my changes, I always open the Changes tab in Android Studio in the top left corner, where all the changes in the code are visible clearly. There you can once again check all the changes made and delete unnecessary ones. And if you suddenly need to switch to another branch without making a commit, you can use the git stash command in the terminal. Then the changes will be temporarily hidden. If you need to show these changes again, this can be done using the git stash apply command.


Once your changes are pushed to the remote repository, other developers in your team can see them and provide feedback - agree or disagree. Following these remarks, you need to fix your code and push your changes again. Once you have peer approval from all of your colleagues, you can merge your changes into the master branch of the repository using the merge button in your common work repository, ex. GitLab. Thus, changes in your branch will be merged into the main branch of the remote repository - master. After that, your task status can be changed to “ready for test.” Done!


If you need to update your project, commit and push your changes, you also can use the bottom in the top right corner of Android Studio.


Git buttons in Android Studio


If you need to merge a branch from a remote repository into your current branch, you can run the following commands:


  • Git checkout “name of the branch you want to merge into your branch.”

  • Git pull

  • Git merge “name of the branch you want to merge into your branch.” ex: Git merge master. Thus all the actual changes in this branch from the remote repository will be merged in your branch.


In Git, you can make changes from one branch to another in two ways: merge, which I mentioned earlier, and rebase. With the rebase command, you can take all the commits from one branch and apply them in exactly the same order to another branch.


The second method (rebase) has an advantage over merge - it allows you to rewrite the history of the branch, giving that history the look you need.


If you don't need to pick up all the commits but only need some, it's convenient to use cherry-pick. This method takes the changes made by a single commit and tries to reapply them as a new commit on the current branch. This feature is useful in a situation where you need to pick up a couple of commits from another branch rather than merge the entire branch with all the changes made to it.


These are the basic Git commands that I use actively in my daily work. In my opinion, they are quite enough for most tasks. But sometimes, a developer has to deal with more complex cases. If you want to learn Git in depth and master this technical tool more professionally, I can safely recommend the following resource: dangitgit.com


I really hope that my article was useful to everyone who is actively interested in Android development and would like to master such a useful technical tool as Git. I wish you success in learning!