Git and GitHub Basics
Published: 2024-03-04 10:46:35

 **What is Git?**
Git is a free and open-source version control system, VERSION CONTROL, it's a way by which programmers/ developers track their code changes - it's the management of changes to documents, computer programs, large websites, and other collections of information.

**Terms used in Git**
Directory - folders

Terminal/command line - interface for text commands

Command Line Interface

CD - Change Directory

Code Editor - for eg. Visual Studio code, replit, notepad, etc.

Repository - A folder/place where your project is kept

**Git vs GitHub**
Git is the tool that tracks the changes in your code over time whereas GitHub is an online website where you host all of your git repositories - it organizes your projects into a portfolio for you to showcase to potential employers/clients; it's a visualization tool for your code.

**Git Commands**
Clone - It brings a repository that is hosted somewhere like GitHub into a folder on your local machine, eg. if there is a repository that is not in your local machine, but it's on GitHub, and you want to bring it down on your local machine, so you can use it locally - clone command.

Add - Its purpose is to track your files and changes in Git, eg. When you have created/updated/deleted files and/or folders, you would want to inform Git that you made changes and that you would like Git to track these changes - add command.
Commit - Saves the files in git, that is, if you want to save the changes you made in your code - commit command.

Push - Upload git commit to a remote repo, like GitHub - once you have committed the changes locally on your computer and you're ready to put them in git, add, and commit, then the next step is to upload them to a remote repo, or a GitHub alternative such as bitbucket, GitLab, etc.

Pull - Download changes from a remote repo(Git Hub) to your local machine - the opposite is push; when there are changes to your code on Git Hub, and you want to bring those to your local machine - pull command. ( you pull down the changes from the GitHub into a local machine.)
readme file - it describes what the project is about, what it does, and any other relevant information- it's like a brief technical documentation of your code.

Init - It is used inside your project from the code editor to turn it into a git repository and now start using git / the terminal with that code base.

Fork - It's a feature on the GitHub website, that makes a complete copy of your repository.

**Installation of Git**
https://www.atlassian.com/git/tutorials/install-git

**SSH Keys**
You gonna have to prove to GitHub that you are the owner of the account - so you have to connect your local machine via Git to GitHub, this is done by use of ssh keys or https.

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

NB: If one didn't have access rights, or needed a code review before we merge changes changes in - pull command.

**Git Branching**
Master- is the naming convention for the default branch in a repository. Branching provides a flexible and powerful way to manage and organize development in a collaborative environment, allowing for efficient and organized version control.

To learn more about git branching:
https://youtu.be/e2IbNHi4uCI?si=cl4V5PJ3tvUJ1RV3

**A Basic Practical Example**
https://youtu.be/wrb7Gge9yoE?si=svPf71-yYxNKYt4n