CS371p: Object-Oriented Programming

Spring 2018: 51620



Git is a powerful program that you must learn to use to help you mange your code.


Configuring git

% git config --global user.name "John Galt"
% git config --global user.email jgalt@example.com
% git config --global push.default simple
% git config --global color.ui true
			

If you're using OS X or Linux:

% git config --global core.autocrlf input
			

If you're using Windows:

% git config --global core.autocrlf true
			

Checking the git configuration

% git config -l
user.name=John Galt
user.email=jgalt@example.com
push.default=simple
color.ui=true
core.autocrlf=input
			

Cloning the class repo from GitHub

% git clone git://github.com/gpdowning/cs371p.git
			

will clone all of the examples, exercises, and projects into the directory cs371p.


Syncing with a repo

% cd my-repo
% git pull
Already up-to-date.
			

Checking the status of a repo

% cd my-repo
% git status
# On branch master
nothing to commit, working directory clean
			

Creating a repo and connecting it to GitHub

% touch README
% git init
% git add README
% git commit -m 'first commit'
% git remote add origin git@github.com:jgalt/my-repo.git
% git push -u origin master
			

Adding to a Repo

% cd my-repo
% git add Foo.py
% git add Bar.py
% git commit -m "another commit"
% git push
			

How to undo (almost) anything with Git

https://blog.github.com/2015-06-08-how-to-undo-almost-anything-with-git/