wiki:project1
Last modified 5 years ago Last modified on 02/03/13 21:11:18

Project 1 is due 11:59pm Monday 4 February 2013. There may be some issues related to submitting your work via git, but let's all make our best effort to make this go as smoothly as possible. What you need to do is push your project1 branch to your private remote. If you are working with a partner, you should merge the final working version into both local repositories and both partners should push identical branches to their respective private remotes.

A working submission should:

  • be in a branch called project1 on your private remote
  • compile
  • run on the local CS network
  • not refer to any paths hardcoded to your home directory
  • have at least two effects, one of which being the split effect

To help get code in the right place, review the following tips

I do not know what branch I am on or what remote branches I have

Use git branch -a to show local and remote branches. You should see something like this

git branch -a
  master
* project1
  working
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/private/project1
  remotes/private/working

The * indicates the local branch you have checked out currently. You want to see a local project1 branch and a remotes/private/project1 branch

I do not have a project1 branch locally or remotely

In this case, commit your changes to the local branch you are currently working on, e.g., mybranch. Then checkout a new branch called project1 and push it to your remote.

git checkout mybranch
git checkout -b project1
git push -u private project1

I am working on a project1 branch, but don't have a remote copy

Switch to your project1 branch and push a new branch to the remote.

git checkout project1
git push -u private project1

I have a project1 remote branch, but I am working on a different branch

Commit your changes to your current branch, e.g, mybranch, checkout the project1 branch, merge, and push

git checkout mybranch
git add               #if needed
git commit            #if needed
git checkout project1
git merge mybranch
git push              #should be configured to push to remotes/private1

I am working with a partner. My partner has the working version

In this case, have your partner push changes to his/her private/project1 remote branch. Merge your partner's changes into your project1 branch and push to your private remote. If you also made changes that your partner needs, make sure your partner pulls your changes too, merges and pushes.

See the wiki page on sharing code with git

If you have conflicts during the merge, see how to resolve merge conflicts

I'm not sure I pushed everything

run git status. If you see anything in the "Changes not staged for commit" section that you think I should have, run git add to add them to the next commit. If you see anything under "Untracked files" that you think I should have, use git add to add these too. See the example below.

git status

# On branch project1
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   myimagebox.cpp
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	../../CMakeLists.txt.user
#	unicorn.png

In this case I might run git add myimagebox.cpp unicorn.png. I do not need to add the CMakeLists.txt.user user file in a directory outside projects/01. Now when I run git status, I see that these files are ready for commit, but not commited yet. Run git commit to commit these changes and add a brief descriptive log message.

git status
# On branch project1
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   myimagebox.cpp
#	new file:   unicorn.png
#
git commit
[project1 51bf983] made project awesome!
 1 file changed, 3 insertions(+)

Now the changes have been committed locally, but not pushed remotely. Run git status to confirm this and git push to send the changes to the remote.

git status
# On branch project1
# Your branch is ahead of 'private/project1' by 1 commit.
#
git push
...
To gitrepos:cs40_adas
   e8d2916..51bf983  project1 -> project1

Now if you run git status or git push you should see

git status
# On branch project1
nothing to commit (working directory clean)

or

git status
# On branch project1
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   ../../CMakeLists.txt.user
no changes added to commit (use "git add" and/or "git commit -a")

We aren't interested in committing this file, so the status is OK.

$ git push
X11 forwarding request failed on channel 0
Everything up-to-date

Don't worry about the X11 message. That shows up all the time.

Questions?

Post to Piazza