James Finnie-Ansley
James Finnie-Ansley
📄 main.py
📄 main_v1.py
📄 main_v2.py
📄 main_v2Final.py
📄 main_v2FINALFINAL.py
📄 main.py
📄 controls.py
📄 controlsV1.py
📄 CoolControllerV4.py
📄 main_v1.py
📄 main_v2.py
📄 controlsV1_withBrynsEdits.py
📄 CoolControllerV5.py
📄 controlsV1_withBrynsEditsV1.py
📄 main_v2FINALFINAL.py
📄 main_v2FINALFINAL_AlexEdit.py
A distributed version control system that lets you:
Commit 1 — Adding new lines:
+ def foo(x, y):
+ result = x + y
+ return result
Three new lines added
Commit 2 — Editing a line:
def foo(x, y):
- result = x + y
+ result = x * y
return result
To Git, one line has been deleted and a new one added.
You can use git locally (on your machine).
You can also connect it to a remote repository
Let’s create a simple Python project that prints a greeting.
Follow along if you like.
If you haven’t already, you will need to:
You need to manage changes to files (code, etc.) over time
Create a Git repository!!
Click "Add"->"Create New Repository"
Fill in the repository name and select the directory you want to create this repository in.
You have made changes to some files and want to record those changes in the repository
Commit the changes!
This is where you can see what has changed since your last commit and select what you want to be in the next commit
This is where you can see what changes have been made within files
This is where you set commit messages and make commits
We're ready to commit the changes!
But...
Your IDE and project have generated files that shouldn’t be committed to the repository
Add a .gitignore
file (See https://gitignore.io)
"I want a goodbye function as well!"
You (and your team) want to independently work on multiple features at the same time
Create a branch for each feature
Branches allow for multiple independent versions of code to be developed at the same time.
Branches can be merged to bring all the changes from one branch into another.
"There’s a typo in the readme! I want this fixed now!"
You are working on a branch with uncommitted changes, but you notice an unrelated bug that needs to be fixed right away
Stash your changes and create a new branch (off of main) to fix the bug
You’ve finished committing changes on your branch and want to add them to the main branch
Merge the branch into main
Now one of your branches is out of date with main!
Update the branch from main.
You have changed and committed the same part of a file on two different branches in two different ways
Resolve the merge conflict in your editor
Merge conflicts happen when the same part of code is changed in different ways on two (or more) branches. In this case, Git doesn’t know how to merge the branches and we need to manually resolve the issue.
<<<<<<< HEAD
This line was changed in one branch
=======
And this same line was also changed in another
>>>>>>> other-branch
but…
You want to be able to work with other people on a project
Host the repository on GitHub
Click "Publish Repository" in the top right
Set the repository name and [optionally] set the visibility to private1
1 As students you should have access to GitHub Pro features
note: make sure you are on the main
branch for this
You’ve committed a change on your machine and want it to be visible on GitHub
Push the changes to GitHub
The branch you are working on has changed on GitHub, but you don’t have the changes on your local machine
Fetch and Pull the changes from GitHub
You have finished work on a feature and want team members to review your change before merging it into the main branch
Publish the branch and create a pull request
For this Interactive Activity we will be adding a list of contributors (i.e. you and your team members) to your CS399 GitHub README.md
Add your CS399 repos to your machine by cloning your CS399 GitHub repository
README.md
file on your main branch (if you don’t have one already)## Contributors
sub-heading to the bottom of the readme workshop_<your_name>
)Get ready for merge conflicts! The only way out is through.
After everyone has committed their changes with their names under the contributors heading:
After that, for this workshop, do the following as a team:
Looking for more? Sink your teeth into Git with these books:
git remote set-url origin <SSH_URL>