Git
Source Code Management
For full documentation visit git-scm.com.
Git is a free, open-source distributed version control system (DVCS) designed to track changes in source code during software development. Created by Linus Torvalds in 2005 to manage the Linux kernel, it allows multiple developers to work on the same project simultaneously without overwriting each other's work. Unlike older centralized systems, every developer's computer maintains a full history of the project locally.
Core Concepts
To understand how Git works, it helps to visualize its three primary local zones:
-
Working Directory: The actual files you are currently editing on your computer.
-
Staging Area (Index): A temporary preparation area where you choose which changes to include in your next save point.
-
Local Repository (.git): The permanent history containing all your saved snapshots (commits).
Essential Git Work
flowA typical workflow tracking a file follows these basic steps:
Modify Files ──> git add (Stage) ──> git commit (Save) ──> git push (Share)
-
git init: Initializes a brand-new local Git repository in an existing folder.
-
git clone
: Copies an existing remote project, along with its full history, to your computer. -
git status: Shows which files have been modified, staged, or remain untracked.
-
git add
: Moves modified files from your working directory into the staging area. -
git commit -m "message": Records your staged snapshot permanently into the repository history with a descriptive message.
-
git push: Sends your local commits to a remote hosting platform.
-
git pull: Fetches and merges the latest changes from the remote server into your local files.
Branching and Merging
One of Git's most powerful features is its lightweight branching system. A branch represents an independent line of development.
-
Developers create a branch to work on a specific feature or bug fix without altering the stable code (usually called main or master).
-
Once the work is thoroughly tested, the feature branch is merged back into the primary branch.
-
If two people change the exact same line of code, Git flags a merge conflict, prompting the team to manually select which changes to keep.
Development Tools
Social Media
---
title: Git
text: Source Code Management
image: /assets/svg/git.svg
link:
target:
---