Skip to content

rohitpawar0208/Git-classroom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 

Repository files navigation

Git-classroom

Git & GitHub Learning Guide

1. What is Git and GitHub?

Git

  • Git is a distributed version control system (DVCS) that tracks changes in files and enables collaboration.
  • Key Features:
    • Maintains a history of file changes.
    • Allows reverting to previous states.
    • Enables branching and merging.
  • Example Alternatives: Mercurial, Bazaar, Darcs.

GitHub

  • A cloud platform for hosting Git repositories and enabling collaboration.
  • Functions:
    • Centralized repository for teams.
    • Simplifies code merging and version control across the globe.
  • Difference:
    • Git: Local version control.
    • GitHub: Global collaboration platform using Git.

2. Setting Up Git and GitHub

Installing Git

  • Download from git-scm.com and install.
  • Verify installation:
    git --version

Installing GitHub Desktop

  • GitHub Desktop: GUI tool for managing repositories.
  • Setup Steps:
    1. Download from desktop.github.com.
    2. Configure using your GitHub account.

Global Configuration

  1. Initialize Git:
    git init
  2. Configure username and email:
    git config --global user.name "Your Name"
    git config --global user.email "youremail@example.com"
  3. Verify configuration:
    git config --list

3. Git Basics and Workflow

Core Concepts

  1. Working Directory: Local files you're editing.
  2. Staging Area: Prepares changes for the next commit.
  3. Local Repository: Stores committed changes on your machine.
  4. Remote Repository: Centralized repository (e.g., GitHub).

Common Commands

  1. Initialize a Repository:
    git init
  2. Add Files to Staging Area:
    git add filename
    git add .  # Adds all changes
  3. Commit Changes:
    git commit -m "Commit message"
  4. Push to Remote:
    git remote add origin <repository_url>
    git branch -M main
    git push -u origin main
  5. Pull Changes:
    git pull origin main

4. Git Branching and Collaboration

Branching

  • Create a branch:
    git branch branch_name
  • Switch to a branch:
    git checkout branch_name
  • Merge branches:
    git merge branch_name

Resolving Merge Conflicts

  • Use a code editor to resolve conflicts.
  • Add changes after resolving:
    git add .
  • Commit the resolution:
    git commit -m "Resolved merge conflict"

5. Learning and Practice Resources

Video Tutorials

Interactive Practice

Reading Material


6. Best Practices

  • Use meaningful commit messages:
    git commit -m "Fix: Resolved bug in login logic"
  • Keep your repository organized with clear branching strategies.
  • Regularly pull changes from the remote repository to stay updated.

7. Advanced Topics

  • Version Control Systems Comparison:
    • Centralized: Subversion.
    • Distributed: Git, Mercurial.
  • Understanding .gitignore:
    • List files/folders to exclude from tracking.
  • Licenses in Repositories:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •