This is supporting documentation for a 25 minute (
Git is a version control system used to track and manage changes made to files. This tool allows teams to work more efficently together and avoid mistakes that might arise from conflicting code, bugs and so on. Benefits of using version control include:
- Ability to track what code has been changed
- Ability to see who has changed it
- Ability to see when it was changed
- And the option to revert to previous versions if needed
Further Reading:
GitHub is a website where you can host code, collaborate with others and utilize Git version control tools. Note: Very important to remember that Git
and GitHub
are two different things. Some features of GitHub include:
- Collaboration (open-source): View other people's code and collaborate on projects.
- Storage: Upload your code to store it remotely vs just on your local machine.
- Hosting: Deploy websites with the option of custom domains
- Management: Automation, manage to do lists (Projects), create Wikis, team organization
- And much more
Alternatives: Gitlab & Bitbucket
Further Reading:
Below are instructions for how to set up Git and GitHub on your computer.
- Create an account on GitHub - https://github.com/join
- Download and install Git - https://git-scm.com/downloads
- For Macs: if you do not already have homebrew installed and are not familiar with using the command line, you can use the Binary installer.
- Download a Text Editor. A text editor is a program that you use to modify and write code. If you do not already have a text edtior, here are some suggestions:
The command line is a text interface that you can use to run commands on your computer. Mac (Terminal) and Windows (Powershell) computers both come with default command lines. You can find and open these command lines by searching for the name (Terminal or Powershell) on your computer.
- iTerm2 (Mac): Powerful terminal replacement for macOS
- Hyper.js: A beautiful, feature filled terminal created with Electron.js
- Terminus (Windows, macOS and Linux): A highly configurable terminal emulator
- eDEX-UI - A TRON/Sci-fi inspired terminal
- Git Bash (Windows - is including when you download Git for Windows)
- Terminal (Mac) Command Line Cheatsheet: A cheatsheet for the Terminal (Mac) command line.
- Command Prompt (Windows) Command Line Cheatsheet: A cheatsheet for Command Prompt (Windows).
- Command Line Power User: A free video course that walks you through customizing your terminal and increasing functionality.
We're going to briefly go over just a few of the most commonly used Git commands below. These will get you started using Git but there are many more commands you can utilize. Check out the resources after this section for more information.
git init
initializes Git. After this command is run, Git will start tracking your files.
- Run inside of a directory (folder). Any changes you make in that folder will then be tracked by Git.
Further Reading:
git status
outputs the status of your files. This is a command that is used very often.
Some information git status can give you includes:
- What branch you are on
- Which files are being tracked
- Which files have been altered
- What the status is of your local branch vs the remote branch
Further Reading:
git branch
creates a new branch, or an parallel snapshot of your project that is seperate from the main
branch.
- Branches are created so that individual engineers can work on the same codebase without impacting the main project code.
- Create a new branch with
git branch branch-name-goes-here
and switch to that branch usinggit checkout branch-name-goes-here
- To create a new branch and switch to that branch with one command use
git checkout -b branch-name-goes-here
Further Reading:
git add
tells Git which files to add to the staging area before comitting.
- Can add all files:
git add .
- Can add individual files:
git add index.html main.css
Further Reading:
git commit
saves a snapshot of your entire project. You run the command with the -m
flag to include a message. This message will typically explain what was changed in the code. Here is an example of what running git commit
could look like: git commit -m “your commit message here”
. You should commit often!
Further Reading:
git push
sends code from your local branch to your remote branch. In this case, it is sending to GitHub.
Further Reading:
For a list additional commands you should learn check out this GitHub Git Command Cheatsheet.
- GitHub Learning Lab: Learn GitHub and Git through guided projects.
- Getting Git Right: Tutorials and guides for using Git.
- Learn Git Branching: An interactive tool to help you visualize how branching in Git works.
- How to Use Git - A Reference Guide: Extensive cheat sheet, explanations and resources for using Git
- Dangit, git!: A list of common git commands used to undo changes.
- Connecting to GitHub with SSH
- Official Git Documentation
Alright, so you now know the basics of using Git and Github. What's next? To become more comfortable using the command line, Git and Github you're going to need to practice. Below is a list of a few suggestions for how to practice on your own and a list of open source projects that have extensive contribution documentation that makes it easier for beginners to contribute.
EmojiScreen is a project I made a couple of years ago to help beginners make their first pull requests on GitHub. The website is a listing of movies, TV shows and musicals depicted through emojis. To contribute, you can add an Emoji Card
that includes five emojis related to the show or movie you want to add so that other people can guess. For more advanced learners, you an also try your hand at adding new features or improving the existing code. Head over to the EmojiScreen repository where there are extremely detailed instructions that walk yoiu step by step through how to contribute!
- Personal Projects
- 100 Days of Code
- Coding Challenges like Codepen Challenges
- Follow people on Github 👀
- Forem/Dev.to - Open source software for building communities
- Gatsby - Build blazing fast, modern apps and websites with React
- Netlify CMS - A Git-based CMS for Static Site Generators
- P5.js - A JavaScript library for creative coding
- FreeCodeCamp - A friendly community where you can learn to code for free