Git + GitHub
git
is a command-line tool, and GitHub is a company built on the underlying git technology. git
is the open-source library (that can be found here: https://github.com/git/git). Git allows you to return to previous versions of a codebase, allowing many engineers to collaborate on a codebase without "breaking" each others work. You can think of it like a fancy file + folder system for code. Around ~75% of companies use GitHub + Git is their primary version control system. Alternatives to Git + GitHub are: SVN, Gerrit, AWS CodeCommit.
Roles that should know | Roles that are nice to know |
---|---|
DevOps, Cloud Engineers, Backend Engineer, Frontend Engineer | Support / Helpdesk, Quality Assurance Engineer |
Key Concepts
- Branches + Pull Requests (GitHub)
- Commits ("Save") + Tags (Version)
- "Branch Strategy" (see: GitHub Flow + Basic Flow)
Exercise 1: Learning the git basics
What you'll learn
Install Git + begin to explore the following commands in a Linux environment. If you need a Linux environment, you can use the Open Cloud Dev Box.
The basic way of using git
git add file.txt
=> Tells git to prepare to be committed.git commit -m "a message"
=> Saves the change.git push
=> Syncs the change with GitHub.
Useful commands
git status
=> This is "home base" on your current state.git push --set-upstream origin garcia-adding-search-feature
=> Pushes a local branch to remote GitHub.
Example Scenario
- You are an employee asked to "make a website for clothing".
- Go and create the clothing website
repo
. - Your first task is to create a "homepage".
- Create a
branch
for your new task and add ahomepage.txt
. Push
the changes and open a pull request.- Comment your own pull request as your "colleague", who asks you to add an image to the homepage.
- Add a file "image.txt" and update the "homepage.txt" content.
Commit
and push this change.- Review your pull request.
- Approve the pull request.
Merge
the pull request.
Repeat the above until you feel comfortable!