Git

From Cheaha
Jump to navigation Jump to search


Attention: Research Computing Documentation has Moved
https://docs.rc.uab.edu/


Please use the new documentation url https://docs.rc.uab.edu/ for all Research Computing documentation needs.


As a result of this move, we have deprecated use of this wiki for documentation. We are providing read-only access to the content to facilitate migration of bookmarks and to serve as an historical record. All content updates should be made at the new documentation site. The original wiki will not receive further updates.

Thank you,

The Research Computing Team

Git is a distributed revision control system with an emphasis on speed. Git was initially designed and developed by Linus Torvalds for Linux kernel development. Every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Git's current software maintenance is overseen by Junio Hamano. Git is free software distributed under the terms of the GNU General Public License version 2.

Git Primer

The above summary is what Wikipedia says about Git. And it is all true.

Unfortunately, that description is very clinical. It's not going to help you understand why you should even bother with Git.

The short answer to why you should bother with Git, is that it helps you maintain a history of changes to your files. By maintaining a history, you can return to an earlier version of your file before "when everything just worked". This useful for all kinds of files, but is especially useful for files that provide instructions to a computer to implement the steps of a process you are documenting.

A longer answer to that question requires knowing a little more about what it means to document a process. You need to know how Git helps you with that work. You need to know the problems Git solves for you and how to get yourself out of a pickle when you find out your instructions are broken.

Most importantly, you need to be able to learn how to use Git along side your normal work. Get started with some basic commands and fix mistakes you discover along the way.

To answer why to use you want to use Git, read the the Git Primer.

Git Basics

The three basic steps for maintaining your history are:

  1. edit a file
  2. add the changes you want to track
  3. commit those changes to your history

Repeat this process as long as you need to.

This process can be used to build elaborate repositories that have a complete history of all the work that went into creating the repository. Git will help you revisit any point in that history.

One Time Setup

Install Git and record your name and an email address where you can be reached.

Tracking Changes

Git assumes you will organize all related files for a project, a set of related files, under a common parent directory. That means, whenever you start working on a new project you should first create a directory that will contain the files that belong to that project.

mkdir mynewproject
cd mynewproject
git init
echo "hello git" > hello.txt # create a file
git add hello.txt  # tell git you want to record the changes made to hello.txt
git commit -m "start tracking hello.txt" # commit the changes to your history


Git for Beginners

Git For Beginners

Git for Developers

UsingGitForDevelopment

Git for MATLAB

Git For MATLAB