GIT Introduction
OST
Introduction to Git
• Git is a distributed version control system (VCS) designed to handle
everything from small to very large projects with speed and efficiency.
Tracks changes in source code during software
Wh development.
y Enable multiple developers to work on a project
simultaneously.
use Provide tools for collaboration and backup.
Git?
Basic Git Concepts
• A directory containing your project and the full history
Repository of all changes.
• A snapshot of your project at a point in time.
Commit
• A parallel version of a repository, allowing multiple
Branch lines of development.
• Combining changes from different branches.
Merge
• Creating a copy of an existing repository.
Clone
• Fetching and integrating changes from a remote
Pull repository.
• Sending changes to a remote repository.
Push
Git Architecture
Working Local Remote
Staging Area
Directory Repository Repository
Git Add
Git Commit
Git Push
Git Pull
Git Checkout
Git Merge
Git Workflow
Set your user Create a new Create a files
Initialize Git
name and directory and to your Add files to
in the
email for Git navigate into project staging area.
directory.
commits it. directory.
Fetch and
merge Create a
Push your Add the Create a
changes from commit with
commits to remote repository on
the remote a message
remote repository a platform
repository to describing
repository. URL. like GitHub.
local your changes.
repository.
Git Commands
git config --global [Link] "username"
git config --global [Link] "register emailid"
mkdir directory_name
cd directory_name
git init
git add <file_name_1> <file_name_2>… or git add *
git commit –m “write commit message”
git remote add origin “Path of your git repository”
git push –u origin <name of main branch>
git pull origin <name of main branch>
git clone “path of remote repository”
Git Branching
Branching in Git allows you to create separate lines of development
within a repository. Each branch can contain its own set of changes,
enabling you to work on different features or fixes independently from
the main codebase.
Master
Develop
Feature
Git Branching Merging and
Checkout
Merging in Git
combines changes
from one branch into
another. It integrates Checkout in Git allows you
the work done in to switch between
different branches, branches. It updates the
ensuring that all working directory to
changes are included reflect the contents of the
in the final version. branch you want to work
on.
Git Branching Commands
git branch <branch_name>
git checkout –b <branch_name>
git checkout <branch_name>
git branch
git merge <branch name>
git branch –d <branch_name>
git branch –d <branch_name>
git branch –m <new_branch_name>
git log <branch_name>
git diff <source_branch> <target_branch>
git branch --merged
git branch --no-merged
git push origin <branch_name>
git push origin --delete <branch_name>
git fetch
git pull origin <branch_name>
Git Stashing
Stashing in Git
temporarily saves
Uncommitte your uncommitted
d Changes changes, allowing
you to switch
Stash
branches or work
Stash
Git
on something else
without losing your
progress. You can
later reapply the
stashed changes
when you're ready
to continue working
Git Stashing Commands
git stash OR git stash save “your message”
git stash list
git stash apply
git stash pop
git stash show stash@{index}
git stash clear
git stash drop
Git Tags and its Commands
• Tags in Git are git tag <tag_name>
markers used to label git tag –a <tag_name> -m “tag
specific points in the message”
git tag
repository's history
as important. They git show <tag_name>
are often used to git push origin <tag_name>
denote release
git push origin –tags
versions, providing a
way to reference and git tag –d <tag_name>
manage snapshots of git push origin –delete
the project at <tag_name>
particular moments.
Other Useful Commands
git status : To check status of working directory and staging area.
git diff : To check the changes in working directory that haven’t staged.
git diff –staged : To check the changes between staging area and last commit.
git log : To show commit history
git blame <filename> : To check who last modified the file.
git reflog : To check the history of all actions like commits, checkouts, etc.
git reset –soft HEAD~1 : Move the head back by one commit but leave the working
directory unchanged.
git reset –hard HEAD~1 : Move the head back by one commit but discard all changes
from the working directory.
git remote remove origin : To remove the added path of remote repository.
Thank You