No tags found on this site yet.

Intro to Git: Version Control Basics

14 May 2022 - [ git  ]

Git: Version Control Fundamentals

Git is a version control and source code management system that keeps track of every change in your code. It’s essential for both individual developers and teams.

Understanding Version Control

A version control system helps you:

Git’s Three-Stage Workflow

Git manages your code through three main stages:

  1. Working Directory: Your current working files
  2. Staging Area: Changes marked for the next commit
  3. Git Directory: Repository containing the complete history

The Basic Git Workflow

Working Directory → Staging Area → Git Repository
    (edit files)      (git add)     (git commit)

Getting Started with Git

Initial Configuration

First, set up your Git identity:

# Set your name
$ git config --global user.name 'agyago'

# Set your email
$ git config --global user.email 'agyago@test.com'

Creating a New Repository

# Create a project directory
$ mkdir project
$ cd project/

# Initialize Git repository
$ git init
# Output: Initialized empty Git repository in /home/agyago/project/

Core Git Commands

The three essential commands for daily Git usage:

  1. git add: Stage your changes
  2. git commit: Save staged changes to repository
  3. git push: Upload local commits to remote repository

Git Workflow Diagram

Repository → Clone → Working Directory
                          ↑
                    Edit/Add files
                          |
                        Stage
                          |
                        Status
                          |
                    Review changes
                          |
                       Commit
                          ↓
                    Git Directory

Key Concepts

Remember: Git is not just a backup system—it’s a powerful tool for managing your code’s evolution over time.

$ git config --global user.name 'agyago'
$ git config --global user.email 'agyago@test.com'
$ mkdir project
$ cd project/
$ git init
Initialized empty Git repository in /home/agyago/project/