Data Science Hub
  • Data Science Hub
  • STATISTICS
    • Introduction
    • Fundamentals
      • Data Types
      • Central Tendency, Asymmetry, and Variability
      • Sampling
      • Confidence Interval
      • Hypothesis Testing
    • Distributions
      • Exponential Distribution
    • A/B Testing
      • Sample Size Calculation
      • Multiple Testing
  • Database
    • Database Fundamentals
    • Database Management Systems
    • Data Warehouse vs Data Lake
  • SQL
    • SQL Basics
      • Creating and Modifying Tables/Views
      • Data Types
      • Joins
    • SQL Rules
    • SQL Aggregate Functions
    • SQL Window Functions
    • SQL Data Manipulation
      • String Operations
      • Date/Time Operations
    • SQL Descriptive Stats
    • SQL Tips
    • SQL Performance Tuning
    • SQL Customization
    • SQL Practice
      • Designing Databases
        • Spotify Database Design
      • Most Commonly Asked
      • Mixed Queries
      • Popular Websites For SQL Practice
        • SQLZoo
          • World - BBC Tables
            • SUM and COUNT Tutorial
            • SELECT within SELECT Tutorial
            • SELECT from WORLD Tutorial
            • Select Quiz
            • BBC QUIZ
            • Nested SELECT Quiz
            • SUM and COUNT Quiz
          • Nobel Table
            • SELECT from Nobel Tutorial
            • Nobel Quiz
          • Soccer / Football Tables
            • JOIN Tutorial
            • JOIN Quiz
          • Movie / Actor / Casting Tables
            • More JOIN Operations Tutorial
            • JOIN Quiz 2
          • Teacher - Dept Tables
            • Using Null Quiz
          • Edinburgh Buses Table
            • Self join Quiz
        • HackerRank
          • SQL (Basic)
            • Select All
            • Select By ID
            • Japanese Cities' Attributes
            • Revising the Select Query I
            • Revising the Select Query II
            • Revising Aggregations - The Count Function
            • Revising Aggregations - The Sum Function
            • Revising Aggregations - Averages
            • Average Population
            • Japan Population
            • Population Density Difference
            • Population Census
            • African Cities
            • Average Population of Each Continent
            • Weather Observation Station 1
            • Weather Observation Station 2
            • Weather Observation Station 3
            • Weather Observation Station 4
            • Weather Observation Station 6
            • Weather Observation Station 7
            • Weather Observation Station 8
            • Weather Observation Station 9
            • Weather Observation Station 10
            • Weather Observation Station 11
            • Weather Observation Station 12
            • Weather Observation Station 13
            • Weather Observation Station 14
            • Weather Observation Station 15
            • Weather Observation Station 16
            • Weather Observation Station 17
            • Weather Observation Station 18
            • Weather Observation Station 19
            • Higher Than 75 Marks
            • Employee Names
            • Employee Salaries
            • The Blunder
            • Top Earners
            • Type of Triangle
            • The PADS
          • SQL (Intermediate)
            • Weather Observation Station 5
            • Weather Observation Station 20
            • New Companies
            • The Report
            • Top Competitors
            • Ollivander's Inventory
            • Challenges
            • Contest Leaderboard
            • SQL Project Planning
            • Placements
            • Symmetric Pairs
            • Binary Tree Nodes
            • Interviews
            • Occupations
          • SQL (Advanced)
            • Draw The Triangle 1
            • Draw The Triangle 2
            • Print Prime Numbers
            • 15 Days of Learning SQL
          • TABLES
            • City - Country
            • Station
            • Hackers - Submissions
            • Students
            • Employee - Employees
            • Occupations
            • Triangles
        • StrataScratch
          • Netflix
            • Oscar Nominees Table
            • Nominee Filmography Table
            • Nominee Information Table
          • Audible
            • Easy - Audible
          • Spotify
            • Worldwide Daily Song Ranking Table
            • Billboard Top 100 Year End Table
            • Daily Rankings 2017 US
          • Google
            • Easy - Google
            • Medium - Google
            • Hard - Google
        • LeetCode
          • Easy
  • Python
    • Basics
      • Variables and DataTypes
        • Lists
        • Dictionaries
      • Control Flow
      • Functions
    • Object Oriented Programming
      • Restaurant Modeler
    • Pythonic Resources
    • Projects
  • Machine Learning
    • Fundamentals
      • Supervised Learning
        • Classification Algorithms
          • k-Nearest Neighbors
            • kNN Parameters & Attributes
          • Logistic Regression
        • Classification Report
      • UnSupervised Learning
        • Clustering
          • Evaluation
      • Preprocessing
        • Scalers: Standard vs MinMax
        • Feature Selection vs Dimensionality Reduction
        • Encoding
    • Frameworks
    • Machine Learning in Advertising
    • Natural Language Processing
      • Stopwords
      • Name Entity Recognition (NER)
      • Sentiment Analysis
        • Agoda Reviews - Part I - Scraping Reviews, Detecting Languages, and Preprocessing
        • Agoda Reviews - Part II - Sentiment Analysis and WordClouds
    • Recommendation Systems
      • Spotify Recommender System - Artists
  • Geospatial Analysis
    • Geospatial Analysis Basics
    • GSA at Work
      • Web Scraping and Mapping
  • GIT
    • GIT Essentials
    • Connecting to GitHub
  • FAQ
    • Statistics
  • Cloud Computing
    • Introduction to Cloud Computing
    • Google Cloud Platform
  • Docker
    • What is Docker?
Powered by GitBook
On this page
  • What is Git?
  • Using Git

Was this helpful?

  1. GIT

GIT Essentials

Last updated 1 year ago

Was this helpful?

This tutorial covers the definition of Git, its basic commands and concepts to help you get started with version control. As you become more familiar with Git, you can explore more advanced features and workflows.

For detailed documentation and specific Git commands, you can use the git --help command or refer to the official Git documentation: .

What is Git?

Git stores the entire project history as a series of snapshots or commits. Each commit represents a specific state of the project at a particular point in time. Developers can work on different branches, allowing for parallel development of features and bug fixes. Once work on a branch is complete, changes can be merged into the main project branch.

Using Git

Let's walk through a simple example to illustrate how Git works in a real-world scenario. We'll create a Git repository, make changes, and commit those changes.

Step 1: Initialize a Git Repository

  1. Create a new directory for your project and navigate to it in your terminal.

  2. Initialize a Git repository in the directory:

    git init

Step 2: Create and Edit Files

  1. Create a new file (e.g., about.html) in your project directory:

    touch about.html
  2. Edit the file using a text editor or code editor to add some content. Save the file. (optional)

Step 3: Stage and Commit Changes

  1. Check the status of your Git repository to see the untracked changes:

    git status
  2. Stage the changes for commit:

    git add about.html
  3. Commit the changes with a meaningful message:

    git commit -m "Added about.html with initial content"

Step 4: Viewing Commit History

You can view the commit history of your project:

git log

The git log command displays a list of commits, including commit messages, author information, and commit timestamps.

Step 5: Create a New Branch

Suppose you want to work on a new feature. Create a new branch for this feature:

git checkout -b feature-branch

Step 6: Make Changes and Commit

Edit the about.html file to make changes. Save the file and commit the changes to the feature branch:

git add about.html 
git commit -m "Added a new feature"

Step 7: Merge Branches

After completing the feature, you can merge the feature branch into the main branch (usually named "main" or "master"):

git checkout main 
git merge feature-branch

Step 8: Push to a Remote Repository

To collaborate with others, you can push your repository to a remote Git hosting service like GitHub:

  1. Create a repository on GitHub.

  2. Add the remote repository to your local Git repository:

    git remote add origin <remote-repo-url>
  3. Push your local repository to the remote:

    git push -u origin main

Set default upstream branch for a local branch if you cannot push your changes:

git push --set-upstream <reponame> main

This example demonstrates how Git can be used for tracking changes, branching, committing, and collaborating with others. Git's flexibility and powerful version control capabilities make it an essential tool for software development and collaborative projects.

Git is a distributed version control system that is widely used in software development to manage and track changes in code and project files. It was created by in 2005 and is known for its flexibility, speed, and robust branching and merging capabilities. Git is designed to help multiple collaborators work on the same project, enabling them to make changes independently and then integrate those changes seamlessly.

Linus Torvalds
Git Documentation