Intro to Git
In this modules we'll introduce the git version control software.
📚 Watch and Read
Git flow using the Github website
These three Rainbow Poem videos cover the standard git workflow. I recommend practice by following along and creating your own poem repo.
Key Terms
- Version control
- Repository or repo
- Commit
- Commit Hash or SHA
- Push
- Branch
- Pull Request
- Merge
- Fork
- Clone
Review
- 📺 Git & GitHub: GitHub Workflow
- 📺 Git & GitHub: Working Locally
- 📺 Git & GitHub: Git Status
- 📺 Git & GiHub: Saved Changes
- 📺 Git & GitHub: Git Pull and Git Push
Git flow using the git CLI
- Login to codecademy using your github account and complete the Basic Git Workflow module
If you'd like to continue watching coding train videos that cover the git CLI, there are two that you may find useful.
Practice using the git CLI on glitch.com
There are a few tweaks you have to make to use git on glitch.com, but in many ways it is similar to setting up git on a new computer.
Because every glitch project is already a git repository, you cannot easily do a git init
. You can however, clone from a github repository instead of using one of glitch's templates (hello-webpage) as we've done in the past.
Login to glitch.com and click New Project
Select the Clone from Github option and paste in the clone URL from the repo you created while following along with Rainbow Poem earlier.
- If you did not follow along with Rainbow Poem earlier, go and create a new github repo on github.com now.
Repo cannot be empty
Glitch requires your git repository to have at least 1 file to clone correctly. Be sure to create a readme or other file before selecting the Clone from github option.
Create new files or edit existing files to make changes we want to push to github
Enter
git add FILENAME
, replacing FILENAME with the actual name of the file of each file you want to add to add to the git staging area.TIP
You can use
git add .
to add all changes at once to the staging area, but be careful as this may add changes you aren't ready to commit.Enter
git status
and verify that all your edits appear in the listEnter
git commit -m "Edits on glitch"
and you will get an error, or a question rather. Git needs to know who you are.TIP
Even though git is installed on your glitch server, it hasn't been configured. This is a step every new computer must undergo before git can fully be used on that machine.
On a normal computer, this is something you do once. Due to the nature of glitch, this is something you'll have to do each time you create a new project (which won't be required after this week, we'll use other methods instead).
Enter
git config user.email "YOUR GITHUB EMAIL ADDRESS"
Enter
git config user.name "YOUR NAME"
Now try entering
git commit -m "Edits on glitch"
again. You no longer get an error and your commit is successfully staged.Enter
git push origin master
and you will be asked for your github username and password.TIP
You may be thinking, didn't I just do this? Not exactly.
In steps 7-8, the email and name you setup was for git itself. Git was asking, "who do I say edited this file if someone asks".
Now, github.com is asking "you say you want to upload these files to a repo on github, I need you to login to github.com to verify you have permission to do that".
Enter your github username when asked, you will see what you type.
Enter your github password when asked. You will not see what you type when typing your password, this is common when a CLI asks you for a password.
Afterwards, if your username and password are correct, you'll see
Counting objects:
and glitch will successfully push your edits to githubGo to the repo on github.com and verify your edits have been made.
Extra Resources
- 📖 https://guides.github.com/
- 💻 https://github.com/git-school/visualizing-git
- 📖 https://git-scm.com/
- 📖 http://git-scm.com/book
- 📖 http://gitref.org/
- 📖 https://help.github.com/articles/git-and-github-learning-resources/
💬 03 Chat
Due: 03/04/19 9 AM
Instructions
The purpose of this chat is to explore uses of Github in your field.
- Use Google and github's explore feature and find a repo that is related to your desired career field in some fashion.
- After reviewing the repo, reflect on these questions.
- Why do you the the creators of the repo put it on Github?
- What other uses for Github can you imagine for your career field?
- Join the the #sp19-03-chat Slack channel and share the URL of your repo and your responses to the questions.
Grading Rubric
% | Explanation |
---|---|
20% | Share the URL of the repo you found earlier in step 1. |
80% | Share thoughtful responses to the 2 questions |
+10% | Extra credit: Engage your fellow students on what you find interesting about their posts, get clarity on something you don't understand, offer help with others ask questions about your example. |
You can always send me questions privately via email, txt, or Direct Message. But I encourage you to ask them in #q-and-a
or in the channel for that assignment (like #sp19-03-chat
) so that you and your fellow students can help each other out. Learning and programming are not solo sports!
📝 03 Journal
Due: 03/04/19 9 AM
The purpose of this journal is to review the concepts covered this week and reflect on how well you understand them.
Instructions
- Visit my codecademy profile and click the Badges button in the middle of the page and ensure you've completed the "Basic Git Workflow" Lesson.
Direct Message
(DM) to Michael Greene (profmikegreene) with two lists.- One for the things you understand most confidently.
- One for the things you are struggling with.
The items in these lists can be vocabulary, assignment tasks, concepts, whatever sticks out in your mind. Try to find at least two items per list and feel free to make them as long as you like.
Grading Rubric
% | Explanation |
---|---|
40% | Having lessons complete badges for the Git lesson in your codecademy profile |
30% | Direct message to profmikegreene containing a list of things you are confident you understand |
30% | Direct message to profmikegreene containing a list of things you are struggling with |
⚛️ 03 Project
Due: 03/04/19 9 AM
The purpose of this project is to prove your understanding of the concepts in this lesson.
Instructions
Click
Channels
in the Slack sidebar to view all channelsJoin the sp19-03-project slack channel
In that Slack channel, you will see a link that will take you to Github Classroom
Click the
Accept this assignment
button and Github will create a version of the project for you.Once this step is complete, the page should say "Your assignment has been created here: https://github.com/RCC-ITP-175/sp19-03-". Click this link and visit your repository.
Create a file called
terms.md
that defines the following git terms in your own words. Review the content here and/or research the web until you're confident in your own definition of the terms.- Version control
- Repository or repo
- Commit
- Commit hash or SHA
- Push
- Branch
- Pull Request
- Merge
- Fork
Create a new file
readme.md
if one doesn't already exist.Make at least 3 commits that add and delete various text to
readme.md
Create a new branch called
patch-1
Edit and make at least 3 more commits readme.md on the
patch-1
branchCreate a new file called
patch-1.md
on thepatch-1
branchCreate a pull request to merge
patch-1
back to masterView the history of your repo visually by clicking the Insights tab and going to Network.
Now, we'll cover the same concepts using the git CLI. Refer to Practice using the git CLI on glitch.com if you encounter issues completing the remaining steps.
- Create a new Glitch project using the
Clone from git repo
option and clone your sp19-03-USERNAME repo - Open the Glitch console and configure git user.email and user.name
- Enter
git checkout -b glitch
to create and checkout a new branch called glitch - Enter
cp terms.md newterms.md
to copy your terms to a new file - Enter
echo $API_SERVER_EXTERNAL >> history.txt
in the glitch console - Enter
history >> history.txt
in the glitch console - Use
git add
andgit commit
commands to add history.txt to the staging area and commit it to the glitch branch. - Enter
git push origin glitch
to push the glitch branch to github - Visit your repo on github.com and click the green
Compare & pull request
button. - Create a pull request.
- Merge the pull request. Be sure to click the
confirm merge
button.
All done!
Grading Rubric
pts | Explanation |
---|---|
5 | Create a terms.md that defines key terms |
5 | Make at least 3 commits using the github website |
5 | Create a patch-1 branch using the github website |
5 | Create a pull request using the github website |
5 | Merge your pull request using the github website |
5 | Clone your sp19-03-project repo on glitch.com |
5 | Create a glitch branch via glitch CLI |
5 | Add your history to history.txt to the glitch branch |
5 | Push your glitch branch to github |
5 | Merge your glitch branch to master on github |