Version Control with Git

Central hub for all Git learning pages

← Back to DevOps Learning

Introduction to Git

Git is a widely used distributed version control system (DVCS) that tracks changes in files and coordinates work among multiple users. It enables developers to collaborate seamlessly, revert to previous versions of a project, and manage code history efficiently across teams.

Key Git Concepts

Repository (Repo): A database where Git stores all project files and their complete revision history. Repositories exist locally on a developer’s machine and remotely on platforms like GitHub, GitLab, or Bitbucket.

Commits: Snapshots of your project at a specific point in time. Each commit has a unique identifier (hash) and a descriptive message explaining the change.

Branches: Independent lines of development that allow teams to work on features or fixes without affecting the main codebase (usually main or master).

Merging: The process of integrating changes from one branch into another, such as merging a feature branch back into the main branch.

Staging Area: An intermediate area where changes are prepared before committing. This gives precise control over what goes into the next commit.

Basic Git Workflow (Command Line)

The standard Git workflow involves making changes locally, committing them, and then sharing updates with others via a remote repository.

# Initialize a new repository
      git init

      # Clone an existing repository
      git clone <repository-URL>

      # Check file status
      git status

      # Stage all changes
      git add .

      # Commit staged changes
      git commit -m "Describe your changes here"

      # Push changes to remote repository
      git push origin <branch-name>

      # Pull latest changes from remote
      git pull origin <branch-name>
      

Tools for Using Git

Command Line Interface (CLI): Provides complete control over Git functionality and is preferred by experienced developers.

Graphical User Interface (GUI) Clients: Visual tools that simplify Git operations, such as GitHub Desktop, Sourcetree, and GitKraken.

Integrated Development Environments (IDEs): Popular IDEs like Visual Studio Code and IntelliJ IDEA include built-in Git support for managing repositories directly within the editor.

← Back to DevOps Learning