2025-05-12 (3 VO): C++ “Door” Exercise Recap, Some Git

C++ Material

Some Git

Add/Commit

  • View changes

    Current working directory somewhere inside the tree,

    $ git status
    ...
    
  • git add changes: stage for next commit

    $ git add file.h file.cpp
    ...
    

    Review repo situation

    $ git status
    ...
    
  • git commit what you staged

    Either non-interactive (giving the commit message as a commandline parameter)

    $ git commit -m 'frobozz the foobar'
    

    Or letting git pop up your favorite $EDITOR

    $ git commit
    

Access Github Over SSH Not HTTPS

This is simpler. HTTPS requires two factor auth and jumping through hoops.

Deploy SSH public on GH ⟶ homework. On Github, You -> Settings -> SSH and GPG Keys. Paste your public key.

Change origin, And Push

../../../../../../../_images/git-workflow.jpg

origin is the default for git pull and git push. We want that these operation always go to something where we have write access - our own “fork”.

Homework

Local C++ Transformation

  • Complete the C++ transformation according to the example in lib/push-button.h and lib/push-button.cpp

    See door sketch in Door Exercise. For all the components in your exercise/firstname.lastname/lib directory, change its implementation from C struct to C++ class.

    • PushButton

    • LightBarrier

    • Motor

    • Door (the C struct has pointer members, and this does not change in the C++ class)

  • Make sure the tests still run

  • Make clean commits in your local repo that you cloned from https://github.com/jfasch/FH-STECE2023.git the other day

Fork on Github, And Change Your origin

Following the procedure outlined in Change origin, And Push,

  • Create a fork of our project

  • In your clone from earlier days, change origin to that fork.

  • Push your repo to the new origin

Submission: Pull Request

To submit, send me a pull request.