CS 458 - Week 4 Lab - 2016-09-14
* Intro to git/GitHub - part 2
=============================
PART of WEEK 4 Lab Exercise - COUNTING as Homework 3, Problem 1 -
INTERSPERSED in intro/notes below
=============================
* everyone should be in a pair (or trio)
* 1 person in each pair should log into
nrs-projects
* so, each pair enters this info (based on the
nrs-projects account you are using):
git config --global user.name "YourFirst YourLast"
git config --global user.email "YourValid@email.whatever"
/* on Mac or Linux -- and nrs-projects is Linux --
set core.autocrlf to input
(use different for Windows)
*/
git config --global core.autocrlf input
* to see your current config settings:
git config --list
* make a file
458lab4-1.txt
...and START it with YOUR pair's/trio's NAMES
and today's date
then:
git config --list >> 458lab4-1.txt
SUBMIT 458lab4-1.txt as it is RIGHT NOW
~st10/458submit w/number 84
* we may be trying the following on nrs-projects:
git clone https://github.com/hsu-cs458-f16/458lab4.git
* NEXT lab exercise step:
* show me you HAVE this as follows:
(DON'T be IN the repo at this point) cd .. to pop out
echo "have repo:" > 458lab4-2.txt
ls 458lab4 >> 458lab4-2.txt
ls -ld 458lab4 >> 458lab4-2.txt
...and submit again, ~st10/458submit, lab number 84
* NEXT STEP
* GO INTO your REPO directory!!
* make a .txt file IN the repo
whose name includes both/all3 of
pair's/trio's first names
sharon-sharon.txt
...and put a no-worse-than-PG13 line of your
choice into that file.
* two-stage commit process:
(still IN the repo directory!)
git add <yournewfile>.txt
git status
* and you should see that <yournamefile>.txt
is ready to be committed
(but not committed yet)
git commit -m "adding our individual new piece"
* this will COMMIT the staged, ready-to-commit
file(s)
git status
* you should see that nothing to commit,
working directory is clean
* what if we now try:
git push origin master
* (note: instructor could do -- she owns repo, though --
NONE of pairs/trios could, I suspect because
not yet *members* of a team with access to the
repository)
git pull
* that worked for SOME pairs/trios, not all;
* to get the latest updated version of the master;
for us, that was the repo we cloned from github
* git config --global core.editor desiredEditorName
git config --global core.editor emacs
* recommended philosophy for commits:
* do small commits often
* BUT at the same time
try to ONLY commit things that COMPILE and WORK
(leave the repo in a GOOD state, always)
* use "social mechanisms" to get people or team members
to do the above
(if you don't have a system with automated
unit checking that only permits such commits)
* SUMMARY: one "flow" for doing stuff in an
existing, non-master repo, pre-branching:
* get the newest version/changes from the
repository
git pull
* make your changes
* check the status of your repo
git status
* add (stage) the changed files
git add newFile.txt
* commit your changes
git commit -m "description of what this update did"
* push the changes to the main/master repository
git push origin master
* BUT!! branches are an important feature of Git,
also;
"alternate universes" where you try things,
pitch 'em if you don't like 'em,
merge 'em into the main if you do...
* basic idea: you can use a branch to explore
an idea, work on adding a particular user story,
work on fixing a particular bug, etc.
* steps:
* create a branch
* check out the branch
* you can create a branch with:
git branch desiredNewBranchName
* desiredNewBranchName exists, but you
aren't IN that new branch yet
* to work IN that new branch, you check it
out:
git checkout desiredNewBranchName
* NOW you have checked out the branch
desiredNewBranchName,
and changes you make and stage and commit
become part of THIS branch
UNTIL you check out another branch
* git branch
...will list your current branches
* git branch -v
...will show the last commit on each branch
* do you LIKE the branch you are in,
that you have staged and committed changes in?
you can MERGE that branch into previous work
(into the master, for example)
to merge into another branch --
FIRST switch branches BACK to the one you
want to merge INTO
if I wanted to merge into the master branch:
git checkout master
THEN use git merge with the branch whose work
is to be merged into the current branch --
if I want to merge newBranch into master,
git merge newBranch
... and you can see what happens,
more on that later