0% found this document useful (0 votes)
11 views7 pages

Git Overview for Beginners

Uploaded by

suresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views7 pages

Git Overview for Beginners

Uploaded by

suresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Mayank Singh

Git Basics and Workflow Guide

What is Git?
Git is a distributed version control system (VCS) that helps track changes in source code
during software development. It allows multiple developers to collaborate efficiently,
maintain versions of files, and revert to previous versions if needed.

Stages of Git
Mayank Singh

1. Working Directory: Where you work on files (write, edit, or delete).


2. Staging Area: A space where changes are temporarily saved before committing.
3. Local Repository: Where committed changes are stored locally on your machine.
4. Remote Repository: Central repository (e.g., GitHub, GitLab) that multiple
developers can access.

What is git init?

git init initializes a local Git repository in a project directory.


Backend Process:
 Creates a hidden .git directory in the folder containing all metadata, configuration
files, and objects required to track changes.
Files Created:
 .git/HEAD: Points to the current branch.

 .git/index: Staging area metadata.


 .git/config: Configuration for the repository.
 .git/objects: Stores objects (commits, trees, blobs).

Workflow: Working Directory, Staging Area, Local Repo


Mayank Singh

1. Working Directory:

o Edit a file (e.g., file.txt).


o Changes remain untracked or modified until added to the staging area.
2. Staging Area (git add):
o git add file.txt moves the file from the working directory to the staging area.
3. Local Repository (git commit):

o git commit -m "message" saves the staged changes into the local repository
with a snapshot.
Example Workflow:

echo "Hello Git" > file.txt # Create file in Working Directory


git add file.txt # Move to Staging Area

git commit -m "Initial commit" # Save to Local Repository

Default Branch
When a repository is created, the default branch is usually main (formerly master in older
Git versions). It points to the latest commit in the local repository.
Mayank Singh

What is a Central Repository?

A central repository is a remote repository (hosted on platforms like GitHub or GitLab) used
for collaboration. It serves as a common location for developers to pull and push changes.

Pull and Push


Mayank Singh

 Pull: Fetches updates from the remote repository to the local repository.
 Push: Sends local commits to the remote repository.
Example:

git pull origin main # Sync local branch with remote


git push origin main # Upload commits to the remote repository

Version Control System (VCS)

A system to manage and track changes in files over time. It allows:

 Collaboration among teams.


 Tracking history and changes.
Mayank Singh

 Reverting to previous versions.

Snapshot in Git

Git saves changes as snapshots of the entire project at a specific point in time. Each commit
is a snapshot of the files in the staging area.

Incremental Snapshot or Backup


An incremental snapshot only records the changes (delta) between the current and previous
commits, reducing storage usage.

Metadata in Git

Metadata is information about the repository, such as commit history, branch details, and
configuration stored in the .git directory.

Branches in Git

 A branch is a separate line of development.


 The master branch (now often main) is the default branch where stable code resides.
Mayank Singh

Workflow:
1. Create a branch:

git branch feature-branch


2. Switch to a branch:

git checkout feature-branch


3. Merge branches:

git merge feature-branch

4. Delete a branch:

git branch -d feature-branch

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy