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.
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:
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!