Intro to GitHub
If you haven't already make sure to sign up for a Github account. If you have an account already make sure to sign in.
We are going to start the intro to github with some simple information about Github. Github is an online service used by developers to store code. Git is a command line tool that helps with version control, in English this means that its like a google doc for code, it saves your past progress in the history if you ever need to go back. Github allows for code to be online for backup reasons and to allow collaboartion between developers online.
Useful terms to know:
- Repo/Repository (git or github): git repo is a folder with the project's code and documents, github repo is the online, "cloud", version of it. This Readme.md is in a github repo.
- Commit (git to github): a Git Commit is when you save your new changes to a commit. This can anything from editing a line of code to creating 5 new files. A commit is essentially a timestamp with what code/files were changes.
- Branch (git or github): git/github branch is something that stores commits. Normally the main code is saved in the "main" or "master" branch. People will create branches when working together. You can create a branch for something like "bug-fix" or "new-feature" or "my-branch". The idea is to separte the new code people are making until it is complete.
- Merge (git or github): Combining git commits from 2 branches. Usually an outside branch into the "main" or "master" branch.
- Pull Request/PR (github): This is when you create a request to merge branches. Often times you create a merge request to "main" or "master" then senior developers/project owners will evaluate your pull request and new commits. They will either ask for changes or merge you new changes into the project code.
- Fork (github): This is when you fork a repo and it's contents to an identical repo on your account. Often times people do this to create changes and create PR back to the main project. Sometimes people do this to create their own spinoff of the project.
In this demo below we are going to go over how the majority of the topics above and how to do them. Follow along using this repo to try things out. Head to this repo if you aren't currently on it https://github.com/lowell-dev-club/github-intro/.
Forking
Lets start by forking this repo. Go to the top right and hit fork, fork it to your account. If you just created an account or haven't fone much on your account forking it to your account should be the only option. For the example below you can see other options availble but just follow along by forking to your account.
Making a commit
Open the names.txt file and edit the file and add your name. After adding your name create a commit message. Usually a commit message would be something like "added 'Rafael' to names list".
Creating a Pull Request
We will now create a pull request to merge your name to the list on the main repo. Its as simple as clicking pull request. Click "create pull request" and thats it. From there you will just finish and a dev club leader will approve the pr and your name will be on the list!
Conclusion
Thats it! This is the basics of github if your interested in learning more check out a more in depth video on our youtube channel: https://www.youtube.com/watch?v=3OtB51Nf4CI