Using git

git is version control software. It is useful for managing code projects, particularly projects with partners. Using git, you will create a remote master repository (repo) for your project. You and your partners then each checkout (clone) a private local copy of the remote master repo, where you can add and commit changes to your cloned copy. To share local changes with your partners, you push them to the master. Any changes committed to a git repo can be recovered if lost.

This guide provides some basics for how to use git for your lab work in this class. It also has links to additional git resources.


Basics of using git for joint CS projects

The first step to using git is to set up a remote bare master repository for your shared project. Next, you and your partner clone local working copies into your own private subdirectories. Finally, you each commit changes to your local copies and push and pull changes to and from the remote master to share work.

This is mostly automated through the use of the setup81 script, shown below:
[~]$ setup81

Usage:
	setup81 <assignment> <partner>

Make a mistake? Reset an unused assignment using
	setup81 <assignment> --reset

You need to specify the lab to setup
Here are available assignments to setup
labs/01  (Partner optional) 
For a partner assignment, suppose partners with usernames Molly and Tejas are collaborating on the first lab. One partner, say Molly, should run
[~]$ setup81 labs/01 tejas
Once Molly's script has finished, Tejas can run
[~]$ setup81 labs/01 molly

Common git commands
git help    # list common git commands  git help --all lists all commands
git add     # add changes or new files to the next commit 
git rm      # remove a file at the next commit
git commit  # commit your changes to your local repository
git push    # push your committed changes to the remote master repository
            # (note: the first time you may have to do: push origin master
git pull    # pull changes pushed to remote master into your local copy 
            # (git will try to merge changes into your copy)
git mv      # move a repo file
git diff    # see a diff between a file(s) and latest commit (local repo)
git status  # see what has changed between your copy and the master version