Creating a Development Environment for Android Apps on Windows – Part 3: Install Git

First post in this series: Introduction to DbTradeAlert

Previous post: Connect a Device

5. Optional: Install Git

About everyone agrees that using a version control system (VCS) is superior to using zip files or having no version control at all. But why prefer Git over say Subversion if you aren’t in a distributed team and won’t do sophisticated branching and merging?

I have two reasons:

  • Git is the most popular VCS and I have little experience with it
  • I want a local VCS without a service running all the time like Subversion (this setup doesn’t use a master repository)

To install Git:

  1. Download the installer
  2. Run the installer as admin if you want to install to the proper directory “C:\Program Files\Git”. Otherwise Git will go into the LocalData folder
  3. In the “Select Components” step uncheck “Windows Explorer Integration” as TortoiseGit will provide that
  4. In all other steps accept the default values and install

A word of caution: this configuration will convert line endings to LF (Unix, OS X) on commit and produce CRLF line endings (Windows) on checkout which is great for collaboration across different operating systems. But everybody on Windows will need an automatic conversion of line endings like just configured.

6. Optional: Install TortoiseGit

The next decision is which UI to use for Git:

  • Use the command line
  • Use Git’s UI – basic task-oriented Tcl/Tk windows
  • Use Android Studio to interact with the VCS – it supports various VCS and even has a VCS-light built in
  • Use 3rd party software like TortoiseGit

This comes down to personal taste. I didn’t want to learn the command line, tried Git’s UI and Android Studio’s and didn’t like those either. But I always liked TortoiseSvn so TortoiseGit is the winner.

To install TortoiseGit just download and run the installer. After restarting the computer your Explorer’s context menu will have 3 additional entries.

To test if the new VCS works locate the project folder – it defaults to “C:\Users\<AccountName>\AndroidStudioProjects\MyApplication”. The first step is to tell Git that you want this folder under source control:

  1. From the folder’s context menu select “Git Create repository here”
  2. Leave the “Make it Bare” option in the message box unchecked and click OK
  3. TortoiseGit confirms that it just initialized an empty repository

Inside the project’s folder this created a new hidden folder named .git which contains the repository. This is typical for Git repositories – no central storage. It also means it’s easy to backup Git reposiories and to get rid of them.

The second step is to commit everything to the new repository:

  1. From the folder’s context menu select “TortoiseGit” | “Check for modifications”
  2. The “Working Tree” window will show 34 non-versioned files and only those will be committed – if you check “Show ignored files” it lists over 1200 files
  3. Make shure only 34 files are listed and click Commit
  4. In the Commit window enter a commit messsage like “Initial commit”
  5. In the line above the file list click “All” to check all files
  6. Finally click Commit
  7. After the files are commited close the progress window and the Commit window

The .git folder grew from 13 files, 8 folders, 28 KB on disk to 87 files, 71 folders, 132 KB on disk.

Mission accomplished – ready to start programming Android apps!

(You can delete the project folder now including the repository)

Next post: Set up a Public Repository

Additional Ressources

Advertisements
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s