Creating a Development Environment for Android Apps on Windows – Part 4: Set up a Public Git Repository

First post in this series: Introduction to DbTradeAlert

Previous post: Install Git

Of course setting up a public Git repository is optional when you create a development environment. I actually did this only when the project was nearly finished – that’s why it’s name “DbTradeAlert” is sprinkled all over this post.

Publishing to a public repository makes the code available to others and creates a free backup facility.

There are various hosting services for Git repositories with the most prominent by far being GitHub. Others are BitBucket, Source Forge, CodePlex, and Google’s recent creation Cloud Source Repositories.

I went with GitHub mostly because it’s the most prominent and I want to learn more about it. A potential problem is that only public repositories are free on GitHub but that’s not a problem for DbTradeAlert.

Still a long way to get to this stage ...

Still a long way to get to this stage …

8. Create a GitHub Account

Creating a GitHub account is straightforward – only username, email address and password are required. The default plan of unlimited public repositories for free is sufficient for public projects like DbTradeAlert.

Now you need to decide whether you want to use HTTPS or SSH to access GitHub:

  • Using HTTPS requires no further preparations as it uses your GitHub account’s credentials. To use SSL you need to generate keys and specify them in your GitHub account as well as in TortoiseGit.
  • You can use a credential helper with HTTPS so you don’t have to enter name and passwort for every push.
  • The HTTPS port will always be open while the SSH port may be closed.
  • With SSH you can use per-project credentials
  • If someone finds out your SSH credentials they still cannot access the account.

Both protocols are secure and if you implemented SSH access you and everyone accessing the repository can still use HTTPS. GitHub have changed their mind about which protocol they prefer and currently recommend HTTPS.

If you will use HTTPS just proceed to add a repository.

To use SSH first generate an SSH key:

  1. Start C:\Program Files\TortoiseGit\bin\puttygen.exe
  2. In PuttyGen click Generate and move your mouse cursor to generate randomness until the key has been generated
  3. Optionally enter and confirm a key passphrase – caching aside you’ll have to enter that password each time TortoiseGit connects to GitHub
  4. Copy the generated key comment
  5. Click Save private key
  6. Use the copied key comment to name the file – important:
    1. Do NOT save this file in the repository as you don’t want your private key to become public!
    2. Be shure to backup this file
  7. Keep the PuttyGen window open

Now go back to your GitHub account in the browser:

  1. In the top right corner select Settings from the dropdown list
  2. In the Settings page select SSH and GPG keys
  3. In the SSH and GPG keys page click New SSH key
  4. Copy the key comment from PuttyGen and paste it into the Title field
  5. Copy the public key from PuttyGen and paste it into the Key field – make shure to copy all of it as Ctrl+A doesn’t work
  6. Click Add SSH key
  7. Enter your GitHub password to continue
  8. Close the PuttyGen window

After a moment you’ll get an email informing you about the new SSH key to prevent misuse.

9. Add a Repository

DbTradeAlert is a somewhat special case because the project already exists in a local repository. It’s easier to create the project in GitHub and then connect TortoiseGit to it.

To add a repository to your GitHub account:

  1. Go to
  2. Log in
  3. Click New repository
  4. On the Create a new repository page
    1. Enter Repository name – “DbTradeAlert for Android” in my case which results in a DbTradeAlert-for-Android repository
    2. Optionally enter a description
    3. Leave Public checked – you need a paid plan to select Private
    4. Initialize this repository with a README: good idea as this file is displayed on the repository’s landing page
    5. Add .gitignore: leave this at None because the project already has a .gitignore file
    6. Add a License: I chose Apache 2.0 because it explicitly states that no trademark rights are granted and changes to the code must be noted. Android uses the same license.
    7. Click Create repository

Initializing the repository with a README is mandatory for creating an empty project simply because Git cannot handle empty folders.

10. Configure TortoiseGit to Connect to the new Repository

Before TortoiseGit can use the remote repository you have to tell it how to connect:

  1. In the project directory’s context menu select TortoiseGit | Settings
  2. Click OK in the message window telling you about Git’s hierarchical configuration
  3. In the Settings window
    1. In the left pane select Git | Remote
    2. In the URL field
      1. To use HTTPS copy the repository’s URL – in my case
      2. To use SSH create an approproiate URL – in my case
    3. The remote field will be initialized with “origin” automatically
    4. If you use SSH specify the file with your private key in the Putty key field
    5. Click Add new/Save – the Remote list has a new entry named “origin”
    6. Click OK

11. Publish the Project

Until now Git has only commited changes to the local repository. Now it’s time to commit to the remote repository. Because having two kinds of commits would be confusing committing to the remote repository is called “push”. Getting changes from the remote repository is called “pull”.

11.1 Pull New Files from GitHub

If you had GitHub create files – like or LICENSE – in the new repository you’ll need to pull them into your local repository first:

  1. In the project directory’s context menu select TortoiseGit | Pull …
  2. In the Pull window
    1. Remote should default to “origin”
    2. AutoLoad Putty Key should be checked
    3. Click OK
  3. You’ll get a TortoiseGitPlink security alert – click Yes to always trust the host

After that TortoiseGit downloads the new files to your local repository and you are ready to push your project. Close the Progress window.

11.2 Fill is the file that’s presented right on your GitHub project’s home page and it should contain the reason why anyone would download your project. I chose to fill it with the introduction to DbTradeAlert for end users – just copied everything from the web page and applied markdown to it. There are sites on the web that provide a preview for the result.

After that commit to the local repository.

11.3 Push Project to GitHub Repository

Finally push the project to the new GitHub repository:

  1. In the project directory’s context menu select TortoiseGit | Push …
  2. In the Push window
    1. Ref | Local should default to “master”
    2. Destination | Remote should default to “origin”
    3. AutoLoad Putty Key should be checked
    4. Click OK

If you use HTTPS you’ll have to enter name and password for your GitHub account.

After that TortoiseGit compresses and uploads the project’s files to your GitHub repository. Close the Progress window.

To check the result go back to your GitHub repository and refresh the page – you should now see your project’s files and the contents of below that list.

11.4 Add an Image to GitHub’s Landing Page

The text in might not be enough to get people interested but a screenshot is worth a thousand words. But where do you store that file?

Most people will want to store it on GitHub itself for ease of maintenance. And the easiest way to do that is to create an issue where you attach the screenshot:

  1. In the project’s GitHub page open the Issues tab
  2. In the Issues tab click New issue
  3. Enter a description like “Screenshot for landing page”
  4. Drag your screenshot into the input area
  5. Copy the resulting URL (<endless string of characters>.png)
  6. Click Submit new issue
  7. Close the new issue

Now that you sneaked the screenshot on GitHub’s server add a link to it in

  1. Open in an editor
  2. Enter the link
    1. in markup: ![App at work](<endless string of characters>.png) if you don’t need formatting
    2. in HTML:  to enjoy full control
  3. Commit the change
  4. Push the change to GitHub

Refreshing your project’s landing page should now show the new eye-catcher.

Note that this is a totally unofficial procedure and may stop working in the future. GitHub also provides personal / organizational and project pages if you need more than just a screenshot and a bit of text.

Next post: Create the Application

Additional Ressources

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: Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s