Assignment 4 - Simple Git
Objectives
- Practice the basic Git commands:
add
andcommit
and, if necessary,reset
- Practice with Git branching and merging
Setup
Have a Terminal open with your seng-201/
as the working directory. Run the command:
git clone https://github.com/llayman/assn4-git-calc
This will create a new subdirectory named assn4-git-calc
that is a “clone” of a Git repository I created.
Open the assn4-git-calc/
directory in Visual Studio Code. You will see two files, calc.py
and .gitignore
. You will do all your work in calc.py
.
Cloning, GitHub, and the .gitignore
file will be explained in an upcoming lab. You can run the clone
command again if you need to delete the directory and start over for some reason.
Instructions
Run calc.py
and to try it out with the options. You are going to add to the functionality.
Part A: Small, incremental commits
Follow the style in the code. Do not worry about our design rules, unit testing, input validation, or error handling.
- Create and checkout a new branch named
more-options
. - Create a separate commit with a brief, meaningful message for each option below. You must have at least two commits to the
more-options
branch:- Add a “power” option to raise one number to the power of another. Stage and commit it.
- Add a “logarithm” option that computes the
log(x, base)
. Import the standardmath
library and use thelog()
function. - The options must be incorporated into the user menu.
- All pre-existing options must continue to work, including “Quit”.
Part B: Merge your work into main
- Checkout the
main
branch and use themerge
command to merge yourmore-options
branch intomain
. - Draw a sketch of your branch history after completing the merge in a style similar to the example below from our labs. Use
git log
to help put it together.- Clearly mark the
main
andmore-options
branches and the position of the HEAD. - Take a picture or draw the history in a file. Put the file in your
assn4-git-calc/
directory, stage it, and commit it tomain
.
- Clearly mark the
Part C: Resolving merge conflicts
I have created another branch, rand
, that adds random number generation to calc.py
. Unfortunately, this will generate merge conflicts with your changes.
- Make sure
main
is the active branch. - Run
git merge origin/rand
- You must resolve the merge conflicts correctly, meaning:
- All of your new options still work.
- My random number generation option works.
- The user menu and all logic is updated to include all options and quit properly.
- Manually run and check all the options.
- Stage and commit to
main
once the merge conflicts are resolved. - Draw a second sketch showing your current branch history.
- Clearly mark all three the branches and the position of the HEAD.
- Take a picture or draw the history in a file. Put the file in your
assn4-git-calc/
directory, stage it, and commit it tomain
. You can combine it with the previous picture into one file if convenient.
Rubric
Partial credit is not awarded for these items: all or nothing.
- (5 pts) Two drawings showing correct Git history.
- (5 pts) Version history of submission shows:
- a minimum of two commits to the
more-options
branch - a merge commit on the
main
branch incorporating the changes from therand
branch
- a minimum of two commits to the
- (5 pts) All options (original features, your additions, and random numbers) correctly work in the final commit.
Submission due November 10
Zip the entire assn4-git-calc/
directory and upload it to Canvas, which will include the hidden .git/
directory containing the local repository. To do this:
- Navigate to the directory containing the
assn4-git-calc/
folder. - Right-click the folder and select
Compress "assn4-git-calc"
- Upload the
assn4-git-calc.zip
to Canvas.
- Open the Windows File Explorer
- In the Navigation Pane on the left of the Filer Explorer, scroll down until you see “Linux”. Double-click it and then double-click the “Ubuntu” or similarly-named folder.
- Navigate to the directory containing your
assn4-git-calc/
directory. It should be something likehome
->your_name
->seng-201
- Right-click the
assn4-git-calc/
directory and selectSend to...
thenCompressed (zipped) folder
. - Right click in the Explorer window and select Refresh. You should see the zip file.
- Upload
assn4-git-calc.zip
to Canvas.
- Open the Files app.
- Navigate to the directory contains your
assn4-git-calc/
directory. - Right-click the
assn4-git-calc/
directory and selectCompress...
, then clickCreate
. - Upload
assn4-git-calc.zip
to Canvas.