Install Git version control

Post date: Oct 08, 2010 2:34:10 AM

You can use Git to copy source code repositories, and create/update your own changes. I've primarily used Git for retrieving copies of other people's projects. This tutorial suggests settings for using Git with MSYS and MinGW.

Installation

Download the latest Full Installer of Git. The current version is Git-2.11.0-64-bit.exe.

  • Run the installer.

  • Accept the GNU GPL. This only affects you if you want to redistribute Git.

  • Change the install directory to "C:\dev\Git"

  • Select Components

    • Uncheck "Additional icons"

    • Uncheck "Windows Explorer integration"

  • Change "Start Menu Folder" to "dev\Git"

  • Select "Use Git Bash only"

  • (Optional) Select "Use OpenSSH", to avoid calling PuTTY from MSYS

  • Select "Checkout as-is, commit Unix-style endings"

  • Select "Enable symbolic links"

Git is installed with your selected settings. It includes it's own installation of MSYS, "Git Bash". My preference is to use Git with my own MSYS installation.

Configuring Git in MSYS

    • Start the MinGW Shell.

    • Edit .profile.

    • Include the git command location on the PATH. You may have done this in the MinGW tutorial.

      • PATH=$PATH:/c/dev/Git/bin

      • export PATH

    • Source the .profile:

    • . .profile

    • Configure Git with your personal information, which will be used when tracking changes:

      • Warning: If you ever create a public repository, these details may be publicly available!

    • git config --global user.name "Your Name"

    • git config --global user.email "your_id@gmail.com"

Cloning a repository

This is the reason I installed Git: to copy other people's source code ;p

You can clone a project by pointing Git at the Git shared URL.

Here is a list of recently updated C++ projects at github.

Let's look at dfhack, a library used for interfacing with Dwarf Fortress. This is their HTTP Git URL: https://github.com/DFHack/dfhack.git . Run these commands in MinGW Shell:

  • cd

  • git clone http://github.com/DFHack/dfhack.git

The online repository is copied to a new "dfhack" subdirectory. Now you have your own local repository.

If you are not behind a firewall, and have access to a Git URL, you can clone the latest release only:

  • git clone --depth 1 git://github.com/peterix/dfhack.git

Tracking changes

Follow these steps to add a test file to your new repository:

  • cd dfhack

  • touch TESTING.txt

  • git add TESTING.txt

  • git commit -m "Added TESTING blank file"

If you don't specify the -m option, the default editor (vim) will open with a commented header. You must add an uncommented message that will explain the purpose of this update. Once you've set your message, save and quit.

Git will list the changes it made in the commit.

What now?

This only covered the bare minimum. If you don't actually care about tracking changes, it's all you need. If you want to use version control, start with the official Git tutorial.