SmartGit GUI Tool

NOTE: This is an old draft post from Thuy (last updated 17 Dec 2012). I’m publishing it because it seems useful and mainly complete. –Brook

What is Git?

Git is a distributed source control version system.  It allows multiple people to work on the same code simultaneously by keeping track of changes made to files.  It visualizes differences between file versions and merges changes from different authors.  It also makes snapshots of file versions, so that you can go back to any version later.  Because git is distributed, you store a copy of the code repository and its change history on your own local machine.  When you are ready, you can sync your files to a remote repository server, such as BitBucket or GitHub.  Syncing to the remote server will share the updated code with all the other users, and they can merge the changes into their own copies if they wish.  Whether or not you use a remote repository server, git will always store your entire repository change history on your local machine.

Git Workflow and Lingo

By default, git will not track files in a repository for changes unless you tell git to stage them.  If you want to make a snapshot of your files, so that you can go back to that state later, you need to commit your files so that the change state is recorded in a git repository index.  When you want to share or backup your code, you push your code to the remote server.

SmartGit

SmartGit is a java graphical user interface for git.  I recommend it for anyone who despises remembering commandline arguments.

Follow these steps in the tutorial to upload your code into an existing BitBucket Repository using SmartGit.

Signup for a BitBucket Account

  • If you are in the Rieseberg Lab, you should have gotten an invite to join the Rieseberg Lab repositories in an email.  If not, bug Thuy Nguyen at thunguye@zoology.ubc.ca.
  • If you can’t wait, then create your own account directly via  BitBucket

Download and Install SmartGit

 

  • Download SmartGit

 

  • You will need Java Runtime Environment (JRE) 1.6 or higher.  Some SmartGit installers are bundled with the JRE.  If you need to install the JRE separately, try the package installer if you are using Linux.  Otherwise, you can download the Sun (Oracle) JRE.  Look for the words JDK or JRE in the download.  Ensure that the download is for your machine’s OS.
  • Find the smartgit installer executable and run it.
  • It will ask you whether you are using a remote server.  Specify BitBucket.
  • Fill in your BitBucket account and password when prompted.

Clone an Existing Repository

  • If you want to contribute to an existing repository from BitBucket, you must clone it on our local machine first.
  • Copy the URL of the BitBucket repository.  For the Rieseberg Lab general repository, it is https://thuy@bitbucket.org/rieseberglab/rieseberglab.git  .
  • Start SmartGit.  It will prompt you to open an existing repository or clone it.
  • If you don’t get the prompt, go to Project > Clone > specify the repository URL for the “Remote Git, Mercurial or SVN repository” > Next
  • All the Rieseberg Lab repositories use Git.  If SmartGit prompts you “Select the type of repository you are going to clone”, select Git.
  • It will prompt you where to put the cloned files.  Select a location on your local disk.
  • When it is done, you should see your directory tree populated with source code from the repository ??? insert pic here ???
  • Verify that the source code was cloned to your local disk.

Stage Files for Tracking

  • If you add new files to a repository, they will not automatically be tracked.  You must stage them first.
  • On your local disk, underneath the directory of your cloned repository, create a file.
  • In SmartGit, toggle the “Show Unversioned Files” button near the left.  It will have the tooltip “If selected, unchanged files will be shown”.  If this is off, untracked files will be hidden.
  • Select the new files that you want to be tracked.  Click the “Stage” button to track those files.

Commit Files as Snapshots in History Log

  • After files have been staged, i.e.  tracked for changes