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.
I recommend using "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.
To add a file, or to stage a file you have changed, use:
git add <filename>
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 *
You should frequently commit staged changes to your local repository with
git commit
This does not push changes to the repository server
Alternately, you can stage and commit all changed files in one command with
git commit -a -m "A helpful message with no punctuation"
This will not add new files, but will stage any changes you've made to already-tracked files.
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 make a mistake and want to roll back any changes you have made, you can use
git stash
Create 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:
Use git fetch -a to pull the list of branches.
Switch 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.
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"
Click "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: