Getting Started with Git Basics

Sep 5, 2024

Introduction to Getting Started with Git

Overview

  • Presenter: Raghav
  • Objective: Learn how to download, install, and use Git to manage projects, with a focus on pushing projects to GitLab.
  • Operating Systems Covered: Windows and MacOS
  • Approach: Basic step-by-step guide.

Step 1: Download and Install Git

  • **For Windows: **
    • Search for "Git SCM" on Google.
    • Visit git-scm.com to download Git.
    • The site auto-detects your OS and offers the correct version.
    • Download the .exe file, run the installer, follow the defaults, and install Git.
  • For Mac:

Step 2: Verify Git Installation

  • Command to Check Installation:
    • git --version
    • Works on Command Line, Git Bash (Windows), or Terminal (Mac).

Step 3: Configure Git

  • Commands to Set User:
    • git config --global user.name "Your Name"
    • git config --global user.email "YourEmail@example.com"
    • Verify by running the commands without the name/email to check settings.
  • List Configurations:
    • git config --global --list
    • Displays current settings including username and email.

Step 4: Create a Demo Project

  • **Create Project Folder: **
    • Example: Create a folder named "Gitlab" and a sub-folder "my first project."
  • Navigate to the Project Directory:
    • Use cd command to change directories in Command Line or Terminal.
    • Shortcut for Windows: In the folder's address bar, type cmd and press Enter.

Step 5: Initialize Git in Project

  • Initialize Git Repository:
    • Navigate to the project folder and run git init.
    • A .git folder will be created, which is hidden by default.

Step 6: Check Status and Commit Changes

  • Check Git Status:
    • git status shows untracked files or changes.
  • Add Files to Git:
    • git add filename or git add . to add all changes.
  • Commit Changes:
    • git commit -m "Your commit message".

Step 7: Push to GitLab

  • Push Changes to Repository:
    • git push -u origin master or git push -u <repository-url> master
    • Use HTTPS URL from GitLab repository.
    • Enter GitLab credentials if prompted.

Step 8: Verify Changes on GitLab

  • Check GitLab Repository:
    • Refresh the GitLab page to confirm changes.
  • Observe Files and Commits:
    • Confirm files like readme.txt and commit messages are present.

Conclusion

  • Practice using Git commands and review your processes.
  • Upcoming sessions will cover more advanced topics like branching and CI/CD with GitLab.
  • Encourage hands-on practice and sharing knowledge.

Additional Resources

  • Git and GitHub Tutorial: automationstepbystep.com
  • YouTube Playlist on Git: Search for Raghav's Git and GitHub tutorials.

Closing

  • Engage with the content and place any questions in the comments for further assistance.
  • Thank you for participating in this Git introductory session.