GitHub Repo
F23_CS11_SI »
Discord
·
Canvas
·
Replit
Table of contents
If you are on Windows, you have probably already installed Cygwin on your device. When you were installing, Cygwin gave you the option to install additional packages, one of these was for Git. Chances are you did not install this, but that is okay we can add packages after installation (kinda). There is no package management in Cygwin outside of the setup program, so you will have to run setup-x86_64.exe again.
- Open
File Explore
then toDownloads
on your device - Search for
setup-x86_64.exe
and open the file - Go through the set up process again (choose the same options as last time) until you reach the
Select Packages
page. Here use the search tool to search for "Git". Choose the package namedGit
with descriptionDistributed version control system
Note: now is a good time to install any additional packages you may want like Vim - Finish the rest of the set up process
- Open your Cygwin terminal and confirm git has been properly installed by running
You should get back something that looks like
git --version
git version 2.39.0
- By default, git should be installed on Mac and Linux systems
- Confirm git is installed by running the following command in your terminal
You should get back something that looks like
git --version
git version 2.39.0
- If you did not get a version number, follow the this guide: Install Git
GitHub is the free web based platform we and many other software engineers use to share and collaborate on projects as well as control version history.
- Go to GitHub and follow the steps to create an account
- Return to the terminal (cygwin or your standard terminal) to configure git
- Set up your username using the following command where
<your_GitHub_username>
is the username you chose when creating your GitHub accountgit config --global user.name <your_GitHub_username>
git config --global user.name CS11SI
- Set up your email using the following command where
<your_GitHub_email>
is the email you used when creating your GitHub accountgit config --global user.email <your_GitHub_email>
git config --global user.email stlheure@cabrillo.edu
-
Open Cygwin as Administrator and enter the following command to configure SSH
ssh-host-config
-
Enter yes for the prompts
-
You will be prompted to with the text below
***Query: Enter the value CYGWIN for the daemon: []
For the value enter
ntsec
***Query: Enter the value CYGWIN for the daemon: [] ntsec
- SSH should already be on Mac and Linux systems
- Generate an SSH key to connect your system to your GitHub account
ssh-keygen
- When it asks for the location to put the file hit enter
- Also just hit enter when it asks for the password, unless you can remember it
- Copy the generated ssh key
cat ~/.ssh/id_rsa.pub
-
Return to GitHub and open your settings by clicking on your icon then ⚙️
settings
-
Scroll to 🔑
SSH and GPG keys
-
Choose a name for the key (something such that you'll remember what computer/system it was for)
-
Paste the key from step 2 into the
Key
box
-
Open the
F23_CS11_SI
GitHub repo in your browser: https://github.com/steph1111/F23_CS11_SI -
At the top of the page click on
-
Follow the steps to fork the repo to your account by creating a new fork. Click on when you are finished. This creates your own personal version of this repository
-
Open your forked repo. At the top of the page click the green button. Open the SSH tab and copy the link
-
Return to your terminal and navigate using
cd
to where you would like this repo contents to live with your file system -
To clone your repo use the
git clone
command and paste the link from step 1. This points to the existing repo on GitHub and makes a connected copy, or clone, on your systemgit clone <link_here>
Here is an example of how I would clone my repo (your link is different)
git clone git@github.com:steph1111/F23_CS11_SI.git
-
To confirm the clone was successful list your files with
ls
. You should see the name of the cloned repo in your current directory
I will be updating my upstream version of your repo before SI sessions to add new content. In order to get the new content into your forked repo you must sync and pull the changes. Every time you want to work on your repo I recommend heading to your forked repo and seeing if there are upstream changes to be synced and pulled
-
Open your forked repo in GitHub. If there are no changes you should see a message that looks like the following stating this branch is up to date. If this is the case it means I have not made changes and you can ignore the following steps.
-
If there are upstream changes to merge there should be a message on this page similar to the following: This means I have main changes to the upstream repo that need to be synced to your fork
-
Click on the button titled 🔄
Sync fork
, you should see a window stating the code is out of date. Click -
Next navigate to your fork on your system
-
Enter the command
git pull
to pull the changes on GitHub onto your devicegit pull
-
Work on the exercises as you would any code on your device
Once you make some changes you would like to be documented you need to commit
them. Committing changes is how you can mark versions of your code you would like to be tracked. It is a good idea to commit changes before and after you add/remove a feature that way there is a record of your changes. Also commit changes after you have finished a session of programming then push
(see following section)
-
To commit changes you use the
git commit
command. The parts of the command are as follows:git
: Denotes we are using a git commandcommit
: The name of the command is commit, this is what we would like to do-m
: This is a flag that says we would like to add a commit message"Message here
: Between quotes state what changes you are committingfile_name
: Replace this with the file you wish to commit
All together the git commit command syntax looks like this:
git commit -m "Message here" file_name
An example commit may be
git commit -m "Added endl to move to the next line" hello.cpp
-
You will receive a short message summarizing the changes
Once you have finished a coding session it is a good idea to push
your commits. The push
command is basically the opposite of pull
. push
takes the changes (commits) you made on your local system and sends them to GitHub. IMPORTANT: always push before you pull!
- Commit your changes (see above)
- Enter the command
git pull
to push the changes from your system to GitHub - You can confirm this worked by heading to Github and seeing the changes reflected on your repo page