Time for action – uploading a project to GitHub
Perform the following steps to upload a project to GitHub:
Ensure the project is open.
Select your project in Project Explorer and from the context menu (right-click) select Team | Share Project. The following screen will appear:
Tip
This and other Git commands are also available by clicking on the cogs icon within App Explorer.
Select the project and click on Create.
Dismiss the dialog by clicking on Finish. Your empty Git repository is now set up locally and integrated with Titanium Studio. The next screenshot shows the changes that have been made, which are as follows:
The name of the branch (master) has been added to the project name
The filenames that are not included in the repository have a question mark
The stars next to the file and folders indicate that there are outstanding changes
To add your project code to the empty repository, right-click on your project in Project Explorer and select Team | Commit.
Add a commit message and move all files from Unstaged Changes using the >> button.
Tip
Make sure that you include the
.project
file and.settings
directory in your staged files. These files contain important project configuration, which is used by Titanium Studio. If these files are missing from a project, the code cannot be run.Click on Commit. Your changes are now committed locally to the repository. Any new changes will be made to a new version on top of the one just committed.
Note
The changes are not on GitHub; the code is still on your machine. You still need to push the code to GitHub.
Create a repository on GitHub if you have not already done so. Copy the location of the repository that is displayed in the box to the right-hand side of Git Read-Only. You will need this for the next step.
Add a remote by right-clicking on your project and selecting Team | Remotes | Add. Leave the remote name as it is. Add your Git repository URL to the Remote URI field.
Now push your changes to GitHub by selecting Team | Push.
Tip
You do not need to add the contents of the
build
directory to your repository. The contents can be created from the source! Clean your project (Project | Clean) before adding any files to it, or better still make sure you ignore thebuild
directory by adding it to the.gitignore
file. The build files significantly increase the size of the project.
What just happened?
Your project code has been uploaded to GitHub and can be seen via the GitHub website. Your code has also been committed so any new changes will be based on this version.
Alternative suppliers
While the examples in this chapter have been based on GitHub, it's not the only player in the field. Titanium should work with any Git-based repository and certainly works with Bitbucket (https://bitbucket.org/). Just add the URL of your repository as a remote before you push your committed changes. Choose the supplier that best meets your needs.