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 want to learn more about 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:
- Download the installer
- 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
- In the “Select Components” step uncheck “Windows Explorer Integration” if you want TortoiseGit to provide that
- 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:
- command line
- Git’s UI – basic task-oriented Tcl/Tk windows
- Android Studio can interact with the VCS – it supports various VCS and even has a VCS-light built in
- 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:
- From the folder’s context menu select “Git Create repository here”
- Leave the “Make it Bare” option in the message box unchecked and click OK
- TortoiseGit confirms that it just initialized an empty repository
The project’s folder now contains a new hidden folder named .git with 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:
- From the folder’s context menu select “TortoiseGit” | “Check for modifications”
- 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
- Make shure only 34 files are listed and click Commit
- In the Commit window enter a commit messsage like “Initial commit”
- In the line above the file list click “All” to check all files
- Finally click Commit
- 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
- Git download: https://git-scm.com/download/win
- TortoiseGit download: https://tortoisegit.org/download/