**WHAT IS GIT AND GITHUB. GETTING STATRED:** **1. What Is Git?** Git is a version control system, which is like a time machine for your code. It keeps track of all the changes you make to your code so that you can go back to any version of it whenever you need. This is super helpful when you're working on a project with others or just want to manage your own code over time. **2. What Is GitHub?** GitHub is a platform where you can store your Git repositories (projects). It makes it easy to share your code with others, collaborate, and track changes. It’s like a cloud storage service specifically for code. ![Screenshot from 2025-01-29 06-56-21](https://hackmd.io/_uploads/BkEiKDvOyg.png) Getting started with Git and GitHub will assist progremmers to manage our code and collaborate on projects. Here's a simple guide to help set up Git on your computer and start using GitHub: **Step 1: Install Git** *Download Git:* Go to the official Git website: https://git-scm.com/downloads. It will automatically detect your operating system and offer the correct version to download. *Install Git:* Windows: After downloading, run the installer and follow these steps. macOS: Can also use Homebrew (https://brew.sh/) to install it with the command: `brew install git` Linux: Can install Git via the terminal with the command: `sudo apt install git` *Step 2: Set Up Git* Once Git is installed, we need to configure it with our personal information so our commits are associated with our identity. Lets head to our terminal or Git Bash. Set our name: `git config --global user.name "Your Name"` Set our email: `git config --global user.email "youremail@example.com"` *Step 3:Install GitHub and Create an Account* Go to GitHub (https://github.com/) and create an account if you don't have one already. After that, you can either use GitHub's web interface or install GitHub Desktop from here (https://desktop.github.com/), depending on your preference. *Step 4: Create a GitHub Repository* Log in to GitHub and click the "+" icon in the upper right, then choose New repository. Give your repository a name and description. You can choose whether to make it public or private. Click Create repository. *Step 5: Connect Our Local Git to GitHub* Initialize a local repository: Navigate to the folder where we want our project. In the terminal, run: `git init` This creates a new Git repository in that folder. Link our local repository to GitHub: After creating your GitHub repository, we'll be given a URL either HTTPS or SSH. To link our local repo to GitHub, run: `git remote add origin` https://github.com/yourusername/your-repo-name.git Replace the URL with the one from our repository. *Step 6: Add and Commit Changes* Create a file e.g., README.md in your project folder. Stage the file for commit: git add README.md Commit your changes: `git commit -m "Initial commit"` *Step 7: Push Our Code to GitHub* Push the changes to our remote repository GitHub: `git push -u origin master` Now, our local files will be uploaded to GitHub. *Step 8: Working with GitHub Going Forward Cloning a repository:* If we want to clone an existing GitHub repository to our local machine, we use: `git clone` https://github.com/username/repository-name.git *To Make changes:* To make changes to files, stage them `git add`, commit them `git commit`, and push them `git push`. *Pulling updates:* When we are collaborating with others, make sure to pull the latest changes from GitHub: `git pull origin main` *Step 9: Explore GitHub Features* Branches: GitHub uses branches to manage different versions of our code. The master or main branch is typically the main branch. We can create new branches to work on separate features or fixes. **3. Git Workflow Overview** ![Screenshot from 2025-01-29 06-55-37](https://hackmd.io/_uploads/SkMM2Uwuyl.png) When working with Git and GitHub, there’s a typical workflow: - You make changes to your code locally (on your computer). - You commit these changes to your Git repository. - You then push your changes to GitHub so others can see them and collaborate. **4. Installation & Config** To get started, you first need to install Git on your computer. Once installed, you set up your name and email so that your commits are properly identified. This can be done using simple commands in your terminal. **5. Sample Project Files** Git tracks changes in your project files, whether it's HTML, Python, JavaScript, or any other type of file. The basic files you’ll use to manage a project with Git are: - `.git` hidden folder where Git stores data about the project - `.gitignore` used to tell Git which files/folders to ignore **6. Basic Git Commands** Here are some basic Git commands that you’ll use most often: - `git init:` Initializes a new Git repository in a folder (turns it into a Git project). - `git status:` Shows which files have been modified, added, or are ready to be committed. - `git add:` Adds files to Git’s staging area, indicating that they are ready to be cgit commitgit commit: Saves the changes you’ve added to your Git repository, creating a “snapshot” of your projeMaking Changes & Viewing Historyng git log git log: Shows a history of all the commits made in the project. You can see who made what changes and when. - You can keep making changes to your code, adding, committing, and tracking progreCreate A GitHub Repository. You can create a new repository on GitHub to store your project. Once created, you'll link it to your local Git reposgit remotegit remote and push your cgit push git pushPushing and Pulling Changesng git push git push: Uploads your commits to GitHub so others can git pull git pull: Fetches the latest changes from GitHub, so your local repository stays up to datReadme FileeadREADME.md. README.md file is used to explain what your project is about. It's a markdown file that you can create and update to document your projec.gitignore Filegnore File This file tells Git which files and folders to ignore (like temporary files, build files, or configuration files) so that they don’t get committed to the repositorCommit Shortcuts Shortcuts Git allows for shortcuts when committing, such as git commit -m "message", which allows you to commit with a message in oneGitHub Interface Basicsterface Basics On GitHub, you can see your repositories, make changes, track issues, and collaborate with others. You can also clone repositories from others to your own local machine to work onSSH Keys14. **SSH Keys** SSH keys are a secure way to authenticate with GitHub without having to type in your username and password each time. You generate an SSH key pair (public and private) and add the public key to your GitHub acgit clone5. **git clone** If you want to work on someone else’s projegit clonese git clone to make a copy of their repository on your local maBranching6. Branching Branching allows you to create a separate copy of your project to make changes without affecting the main project. You can later merge your changes back into the main project. **Pull Requests** When you want to contribute to someone else's project, you make changes in a branch and then create a pull request to ask the project owner to review and merge your changes into the main project. **Merging** When you finish working on a branch, you can merge it into the main branch, incorporating your changes into the main codebase. **CI/CD Pipeline with Vercel** CI/CD stands for Continuous Integration and Continuous Deployment. It automates the process of testing and deploying your project. With tools like Vercel, your code can be automatically deployed to the web every time you push new changes to GitHub, making it easier to see your work in action. **Summary** - Git: A tool to track changes in your code. - GitHub: A platform to share and collaborate on Git repositories. - Workflow: Add changes, commit them, push to GitHub, and pull changes from others. - Branching & Merging: Work on separate branches and merge them to keep the codebase clean. - Automation: CI/CD tools like Vercel make deploying changes fast and automatic. *Reference :* https://www.youtube.com/watch?v=vA5TTz6BXhY