Project

General

Profile

Git

UNDER CONSTRUCTION - USE WITH CARE and please report opportunities for improvement to Mark Anderson

Git is a now popular tool for managing versions of files. It is in some respects similar to Subversion which became widely used before git was developed - much as Subversion was developed in 2000 to replace the commonly used version control Concurrent Versions System (CVS) ( https://en.wikipedia.org/wiki/Concurrent_Versions_System ).

Obtaining the Software

For Windows Subversion we use TortoiseSVN. For Windows Git we can use TortoiseGit, available at: https://tortoisegit.org/download/. Almost all of our PC's are 64 bits now so be sure to download that version.

Getting Started for Git Users

This section applies to client, students, faculty and staff who need to access a git repository. Users dop not have the ability to create a new git repository - only the system administrator can.

This section assumes that you have already installed Git according to the instructions for your operating system

Windows Users - TortoiseGit

TortoiseGit is accessed by right-clicking on a Windows explorer folder.

Typical Command Line Usage

This is the user sequence for the command line on Mac or Linux or for Windows users with Cygwin.

# one time only to get started
mkdir my-project
cd my-project
git init
git remote add origin https://designlab.eng.rpi.edu/git/my-project
# you'll be prompted for EDN user name and EDN password

# for convenience, set your RPI email and real name
git config --global user.email "RCSID@rpi.edu" 
git config --global user.name "Your Name Here" 

# done before starting any work, each time work is to be done
git pull origin
# you should now have a copy of all that ws on the server

# do work

# tell git to pay attention to everything or to only specific for
git add . (or specific files)
# tell git to add them to the local "repository" 
git commit -m "reason for commit" 

# tell git to send them up to the cloud where others can access things
git push origin master
# if the push command fails you may need to do this one time before you can push
# it tells git where the push goes within the cloud
git push --set-upstream origin master

# list what is in the remote. No details unfortunately as subversion supports
# it will prompt for username & password
git ls-remote

Creating a Git Repository on the EDN Server

This is an administrator-only function!

This script will perform the steps required to create the repository on the EDN server. While the user's repository on their PC is referred to as their "local" one, this is referred to as the "remote" repository.

#!/bin/sh
# Mark Anderson
# create new git repository

name="$1" 
gitloc="/data/git" 

# check if name was provided on command line else prompt
if [ -z "$name" ]
then
        echo "Enter new git repository name:" 
        read name
fi
# make sure a name was provided
if [ -z "$name" ]
then
        echo "git repository name required! Exiting..." 
fi

echo "Git repo $name will be created & initialized at $gitloc/$name" 
sudo git init --shared --bare   $gitloc/$name
sudo chown -R www-data:www-data $gitloc/$name
sudo chmod 755                  $gitloc/$name

Notes

The above script could be enhanced to confirm that the requested repository does not already exist.

It is NOT valid to create a git remote repo on the server and then simply copy it to another name. The above commands must be run to create each new repository.

Configuring the git Repo within the EDN

While configuring a Subversion repo requires the URL to the repository, configuring a git repo requires the on-disk local file system path to the repo, e.g. "/repo-location/git/repo-name" where repo-location is the folder where we are keeping all repositories.