I recommend the Git SCM tutorial, found at http://git-scm.com/book
On the github page for the repository, click on the green Clone or download button.
You need to use "Clone with SSH." If the box reads "Clone with HTTPS", click "Use SSH."
If that is not available, set up your SSH key.
Click the copy button next to the link.
To clone your repository into the directory, use
git clone <link>
To update the repository with any changes made, for instance by staff or other members of a group project, use
git pull
It is a good idea to use git pull every time you start working, just in case.
When you are ready to commit your changes, use
git commit -a
If you want to avoid writing the message in vim, you can specify the message on the command line iwth
git commit -a -m "A helpful message with no punctuation"
When the coded is in a good state, such that it compiles, it's a good idea to push your changes back to Github. Use:
git push
This uploads all changes to the git server. Since course staff gets your code from the server, this how you will submit your projects.
Make sure that you push!
If you don't want to commit changes to every file, or you want to add a new file, use
git add <filename>
git commit -m "message"
It is okay to have untracked files.
You should never add generated files, such as executable or object files, to your repository.
Never use git add *
If you make a mistake and want to roll back any changes you have made, you can use
git stash
To check the current status of the repository, use
git status
For the group project, you should make a branch for every component you want to add to the project. A series of tightly related functions (i.e. 'isValidMove' and 'makeMove') could go in the same branch, but functions that are connected but distinct (i.e. 'makeMove' and 'findAllMoves') should be in separate branches. After the task is finished, the branch should be merged back into master and then deleted.
To make a branch:
Go to the Code tab of your project on GitHub
Click the Branch drop-down box
Enter a new branch name.
On your local computer:
Pull the list of branches with
git fetch -a
Switch between branches using
git checkout <branch>.
You can commit, push, and pull as normal.
If you edit the wrong branch, a git stash will roll back any changes you made since the last commit.
To merge a branch back into master:
Be sure you have pushed your code.
On the Code tab of your Github Project, click the Branches sub-tab
Click the "New pull request" button for your branch.
You will be notified if there are conflicts.
Either way, click "Create pull request"
With no conflicts, click "Merge Pull Request" and "Confirm Merge"
If there are conflicts:
Click the "Resolve Conflicts" button
One version is between the <<<<<< and ========
The other is between the >>>>> and =======
Replace everything (including <<<<<< and >>>>>) with code that works for both branches.
Click "Mark as Resolved"
When all files have been resolved, click "Commit Merge."
Do a git pull to double-check your resolved files on the branch.
Then you can "Merge Pull Request" and "Confirm Merge"
Since the branch is finished click "Delete Branch."
Before:
After: