Part 1: Setup

Go forward, or back in time, with Git.

Have you ever accidentally deleted code? Do you wish you could go back in time to recover that Kotlin class you deleted because you thought it wasn't being used?

If you've ever lost code, you'll be thankful to know that Git can save your project every hour so that you can go back last week to see that Kotlin class.

I use Git all day long and it has helped a lot. I probably make a commit -- a copy of your project -- every 20 minutes. I also create a new branch for all features I add or bugs I fix.

Git is open source and freely available. On Windows, download from the git website. On Mac, Xcode should install git. On Ubuntu, install with apt install git.

If I'm working on adding a new screen to the app, I'll first create a new branch called add-login-screen. If in an hour I make a mistake, I can always go back to this add-login-screen version of the Android Studio project.

After 2 hours I finish creating the login screen, and we can merge add-login-screen branch into the master branch. It's possible to have multiple branches of a project. At work, I have about 10 different branches. For example, here are some of the branches:

  • master
  • fix-bug-492
  • add-login-screen
  • fix-recyclerview
  • feature-big-red-button

After adding the big red button to the app, I can combine feature-big-red-button into master. Think of each branch as a separate Android Studio project. It takes 2 seconds to switch from branch to branch.

One of the advantages of using Git is that multiple people can be working on the app at the same time. If Jacob is working on fix-bug-492, Brad is working on add-login-screen and I'm working on fix-recyclerview, at the end of the day we can combine all of our branches into a single branch, master.

As an example of the power of git, let's look at a log for one of my YouTube projects, the Android Ecommerce App. Here is the git log for that:

Every time I finish a video, I make a commit -- or snapshot -- of the codebase. That way I can always go back to a previous snapshot to see what the code looked like last week, last month, or last year. Not having to open a separate folder of a back is helpful. If you want to view the difference between two commits, you can view the diff. In this example, the left side of the screen is the old code, and the right side of the screen is the new code. Very handy!

Part 2: Your First Commit

More Tutorials

Android Basic Alert Dialog Box
Basic CardView

Basic CardView

Material Design.

Rounded Corners with a Border
Rounded Button in Android Studio

Rounded Button in Android Studio

Create beautiful buttons in XML.

RecyclerView Day 3: Invoicing app

RecyclerView Day 3: Invoicing app

Built with Android Studio and Kotlin.

Build a Ridesharing Android App - Part 1

Build a Ridesharing Android App - Part 1

Getting started is sometimes the hardest part.


Add a click listener in Kotlin.

Android Login Layout

Let users sign in.

Registration Screen

Registration Screen

It always begins with registration.