|It is crucial that you read and understand these
instructions all the way through before beginning, then:
think about what each step is trying to achieve,
before you hit enter, re-read what you actually typed in,
read and try to understand any warnings or error messages that are displayed before proceeding further...
Cutting and pasting chunks of instruction into your command window has a high probability of blowing up
This project code, examples, assignments, quizzes, labs, and other related material may be distributed and collected through the use of the git version control tool.
The basic idea is as follows, detailed instructions are provided afterwards:
|I strongly recommend students become comfortable
with the basic use of each of the following git commands:
add, commit, branch, checkout, merge, tag, revert, rm, show, push, and fetch as well as basic familiarity with gitk
(quick reference for git stuff here)
Note that the examples below are based on csci265 and an assignment named phase1, you will need to make appropriate substitutions in the commands if you are using these instructions for a different course or for another lab/assignment/project phase.
Step 1 is done once only at the start of the first lab, while steps 2-4 will be done once for each assignment/lab/project phase.
|For each of steps 2-4 check that you are entering the command as shown below, your only substitutions should be for the course number (instead of 265) and the assignment name (instead of phase1). Be very careful, and be sure you complete each step successfully before moving on to the next. Only do step 5 if/when the instructor explicitly asks you to.|
*If you find you are getting warnings about x11 when you run the ssh command, you can include the option -x to prevent them.
|Note that this creates a repository of your own on the central server containing a copy of the instructor's repository, including all the branches.|
If step 2 or step 3 didn't work, and all you see in the new repository
is a single default README file
(e.g. if you forgot to fork, or made a mistake in the fork command but did the clone anyway),
or you simply want to start all over, then you can try the following fix:
If you would like to see what you have put in the trash,
ssh csci D list-trash
If you would like to get something out of the trash, use the name/date of the file to restore as seen in the listing above, e.g.
ssh csci D restore csci265/$USER/phase1/2016-02-10_14:00:00
Type in ls to verify that the expected files were copied across.
Note: hopefully git will soon allow us to drop the term "master" to refer to the
original branch, replacing it with something like "primary"|
If an update is issued you can retrieve it using
(5a) git fetch instructor
You can then see what has changed using
(5b) git diff HEAD instructor master
You can then make any changes needed and merge the instructor's master into yours with
(5c) git merge instructor master
Note that if there are conflicting changes between the instructor files and your own then it will let you know what files need to be edited to resolve the changes, and once it completes it will open an editor window for you to enter a commit message.
An alternative is to use
git pull instructor master
which will automatically carry out the merge (fetch is nice/safer in that you can use git diff to see what has changed and then choose whether or not to begin the merge process).
Again, you may need to resolve conflicting changes and it will open an editor window at the end for you to enter a commit message.
Commit whenever you have a new feature working or when you are about to try a change that might not work out.
What to do if, on that final push, you get an error like this:
FATAL: W any csci265/phase1 YOURUSERNAME DENIED by fallthru (or you mis-spelled the reponame) fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.Note the push should be trying to push to "csci265/YOURUSERNAME/phase1", not to "csci265/phase1" (which is the instructor repo), so this error message suggests that step 4 you cloned the wrong repo, e.g.
git clone csci:csci265/phase1
instead of the correct step 4
git clone csci:csci265/$USER/phase1
so now, in step 8, when you push it's trying to push to the instructor version and giving you that permission error.
To fix this, we need your repo to think it was cloned from *your* space
on the git server, not from the instructor's, so we'll reset where
your repo points its "origin" to using the following command:
After that, you should be able to push normally.
More options to explore:
If you want to check for added or committed differences between your current
local repository and your central repo, use
git diff origin/master...HEAD
(It should come up with nothing if you've pushed all your changes, but it won't detect local changes without the appropriate git add.))
You can check the status of your local repository (to see if you've forgotten
any adds or commits) using the command
If you want to push another branch, use the command
If you want to push all branches, use the command
|Note the commands above assume the master branch is the
one of interest.
If you want to see if there
are other branches available you can use the command
git branch -a
If you want to then copy any of those branches to your local version you can use the command
git pull origin NameOfTheBranch
If you want to clone a specific branch you can use the following
git clone csci:csci265/$USER/item --branch thebranchname