Media Computation Skills Lab

MTEC 1003 - Fall 2016

Lab 6 - Prep - Creating Local and Remote Repositories

In this lab, you’ll be:

  1. creating two repositories, one local and one remote
  2. linking the two with each other so that they can be synchronized
  3. associating a name and email address with your local repository
  4. creating a README.md file to describe your lab
  5. sending those changes to your remote repository on github

Summary of Commands:

THESE ARE NOT LAB INSTRUCTIONS.

The following is just a reference. The lab instructions are below.

# create a local repository
git init

# configure it with your name and email
git config user.name  "your name"
git config user.email "your@email.address"

# create a remote repository
curl -u 'your github user name' https://api.github.com/user/repos -d '{"name":"your repository name"}'

# link the two
git remote add origin url_to_your_repository_on_github

# two ways to show all remote repositories
git remote -v
cat .git/config

# removing a remote repository by name (usually origin)
git remote remove name_of_remote

# changing / setting the url of a named remote repository (usually origin)
git remote set-url name_of_remote new_remote_url

# look at the differences between your last save and your current changes (line by line)
git diff --color

# check on the status of your changes
git status

# "stage" or mark your changes as ready to be saved
git add --all

# save!
git commit -m 'my message'

# show a log of your changes so far
git log --color (show your changes so far)

# send to a remote repository (to submit an assignment)
git push origin master 

Instructions

Set up Your Local Repository

This will create a local git repository to store your work for this lab. The repository will be in ~/Desktop/yourname/lab-06-javascript-conditionals.

cd ~/Desktop
mkdir myname
cd myname
mkdir lab-06-javascript-conditionals
cd lab-06-javascript-conditionals
ls -al
total 0
drwxr-xr-x  2 bree  staff   68 Feb 26 07:52 .
drwxr-xr-x  3 bree  staff  102 Feb 26 07:52 ..
git init
Initialized empty Git repository in /Users/bree/Desktop/bzuckerman/lab-06-javascript-conditionals/.git/
ls -al
ls .git
# in the directory of your repository
git config user.name  "my first and last name"
git config user.email "my@email.address"
git config -l

Create Your Remote Repository

This will create a remote git repository on github. It will also link your local repository with this remote repository. In order to submit your work, you will send your files / changes from your local repository to the remote repository on github.

curl -u 'your github user name' https://api.github.com/user/repos -d '{"name":"lab-06-javascript-conditionals"}'
Enter host password for user 'bzuckerman':
{
  "id": 17210769,
  "name": "lab-06-javascript-conditionals",
  "full_name": "bzuckerman/lab-06-javascript-conditionals",
  "owner": {
    "login": "bzuckerman",
	...
}
git remote -v
git remote add origin https://github.com/your_github_user_name/lab-06-javascript-conditionals.git 
git remote -v
origin	https://github.com/bzuckerman/lab-06-javascript-conditionals.git (fetch)
origin	https://github.com/bzuckerman/lab-06-javascript-conditionals.git (push)

Creating and Saving Changes Locally, Sending to Remote Repository

In this part of the lab, you will create a text file in your local repository, and then you’ll send it to your remote repository.

git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	README.markdown
nothing added to commit but untracked files present (use "git add" to track)
git add --all
git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#	new file:   README.markdown
#
git commit -m "added a README file"
[master (root-commit) 5b24d27] added readme
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README.markdown
git status
# On branch master
nothing to commit, working directory clean
git log --color
commit 5b24d2777a602908978916ca8fe9c8dd2ed6036b
Author: bree <bzuckerman@citytech.cuny.edu>
Date:   Wed Mar 5 11:45:21 2014 -0500

    added readme
git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 242 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/bzuckerman/lab-06-javascript-conditionals.git
 * [new branch]      master -> master
This is lab 06...
It's about JavaScript conditionals.
git diff --color

MTEC 1003 - Media Computation Skills Lab - Spring 2015