Sobes.tech
Intern

What is Git?

sobes.tech AI

Answer from AI

Git is a distributed version control system (Distributed Version Control System, DVCS).

Main features:

  • Distributed: Each developer has a full copy of the repository, including the entire history of changes. This allows offline work and simplifies backup.
  • Version control system: Tracks changes in the project over time, allowing you to revert to previous states, compare versions, and merge work from different developers.
  • Snapshots, not differences: Git stores the state of the project as snapshots, not just lists of changes between versions. This makes comparison and branch switching operations very fast.
  • Branching: Creating and merging branches is a fundamental and lightweight operation. It allows isolating development of new features or bug fixes.
  • Staging area (index): An intermediate area between the working directory and the repository, allowing flexible management of which changes will be included in the next commit.

Key commands:

# Initialize a new repository
git init

# Clone an existing repository
git clone <url>

# View the status of the working directory and index
git status

# Add changes to the staging area
git add <file> # or git add .

# Create a commit
git commit -m "Commit message"

# View commit history
git log

# Create a new branch
git branch <branch_name>

# Switch to another branch
git checkout <branch_name> # or git switch <branch_name>

# Merge branches
git merge <branch_name_to_merge>

# Push changes to a remote repository
git push

# Pull changes from a remote repository
git pull

Workflow scheme:

  1. git clone
  2. Working changes
  3. git add
  4. git commit
  5. git pull (if needed)
  6. git push

Git is the de facto standard in modern software development.