0% found this document useful (0 votes)
45 views15 pages

Introduction To Git: Arunan J Neeraj N Lokhith

The document provides an introduction to Git, a distributed version control system, covering its key features, basic commands, and concepts such as repositories, branching, and merging. It emphasizes the importance of version control for collaboration and managing changes in software development. Best practices for using Git effectively are also highlighted, including committing frequently and using branches for feature development.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views15 pages

Introduction To Git: Arunan J Neeraj N Lokhith

The document provides an introduction to Git, a distributed version control system, covering its key features, basic commands, and concepts such as repositories, branching, and merging. It emphasizes the importance of version control for collaboration and managing changes in software development. Best practices for using Git effectively are also highlighted, including committing frequently and using branches for feature development.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

INTRODUCTION TO GIT

ARUNAN J
NEERAJ N
LOKHITH
AGENDA :
Introduction to Version Control
Introduction to GIT
Key features of GIT
Basic GIT Commands
Repositories
Branching and Merging
Resolving Conflicts
Collaborating with GIT
Conclusion
VERSION CONTROL
• Version control is a system that records changes to
files over time, allowing the user to track and
manage different versions of those files.
• Versioning : Version Control System saves the
new vsion after a change is made and keeps a
history of previous version .
• Collaboration : Multiple people can work on the
same project simultaneously and VCS tracks the
changes to avoid risk of conflicts .
• Branching and Merging : Branches (separate lines
of development) can be created and can be
merged back .
• Repositories : It is a storage space for the project
and its version history .
INTRODUCTION TO GIT

• A distributed version control system


(VCS) for tracking changes in source
code .
• Developed by Linus Torvalds in 2005 ,
primarily for Linux kernel
development .
• Every user has a complete copy of
the repository, allowing offline work.
• Git is widely used in software
development for managing source
code and enabling collaboration in
projects.
K E Y F E AT U R E S O F
GIT
Distributed: Each developer has a complete
local copy of the entire repository
Fast and Efficient: Optimized for speed and
handles large projects effectively.
Branching and Merging: Easily create and merge
branches for feature development or
experimentation
History Tracking: Maintains a log of all changes
made to the project
Staging Area: Allows you to prepare commits in
a staging area before finalizing them.
BASIC GIT COMMANDS
• git init: Initialize a new Git repository.
• git clone: Copy an existing Git repository to
your local machine.
• git add: Add files to the staging area for the next
commit.
• git commit: Save changes to the repository with
a descriptive message.
• git push: Upload your local changes to a remote
repository (like GitHub).
• git pull: Fetch and integrate changes from a
remote repository
• git status: View the current state of the
repository.
REPOSITORIES
• A repository (repo) is a storage location where all the files
of a project and its complete version history are kept.
• It tracks all changes made to the project, allowing users to
collaborate and maintain multiple versions of the project.
• Types of Repositories:
Local Repository: The repository stored on your
computer where you work and make changes.
Remote Repository: The repository hosted on a server
(e.g., GitHub, GitLab) for collaboration and backup.
• Creating a Repository:
git init: Initializes a new empty Git repository in the
current directory.
git clone <url> : Creates a local copy of an existing
remote repository.
REPOSITORIES Contd..
Components of a Git Repository:
• Working Directory: The actual directory where files are edited.
• Staging Area (Index) : A place to store changes before committing
them.
• Commit History : A record of all commits (snapshots of changes)
made to the repository.

Common Repository Operations:


• git add <file> : Adds changes to the staging area.
• git commit -m "message“ : Saves staged changes with a descriptive
message.
• git push : Uploads local commits to a remote repository.
• git pull : Fetches and merges changes from a remote repository.
Branching
A branch , allows to work on different features or bug fixes
without affecting the main codebase.
Git’s branching is lightweight and allows for easy context
switching between tasks.
Key Concepts:
Main (or master): The default branch where stable
production code usually resides.
Feature Branches: Separate branches created for
developing new features or fixes. E.g., git checkout -b
feature-x.
Isolation: Changes made in a branch don’t affect other
branches until they are merged.
Common Branching Commands:
git branch : Lists all branches in the repository.
git checkout <branch-name> : Switches to the
specified branch.
git checkout -b <new-branch> : Creates and
switches to a new branch.
Merging
Merging combines changes from one branch into another (usually the
main branch), integrating the work done in different branches.

Key Concepts:
Fast-Forward Merge: If the main branch hasn’t changed, Git simply
moves the branch pointer forward.
Three-Way Merge: If both branches have changes, Git uses a common
ancestor to merge them.
Merge Conflicts: Occur when changes in different branches conflict. Git
will prompt you to resolve these manually.

Common Merging Commands:


git merge <branch-name> : Merges the specified branch into the
current one.
git merge –abort : Cancels an ongoing merge in case of conflicts.
• Conflicts occur when Git cannot automatically merge changes
Resolving because different branches have modified the same part of a file
in conflicting ways.

Conflicts • Happens typically during merging or rebasing.


When Do Conflicts Arise?
• Merging branches with conflicting changes.
• Pulling updates from a remote repository into a local branch with
local modifications.
• Rebasing commits on top of another branch that has conflicting
changes.
Steps to Resolve Conflicts:
1.Open the conflicting files and locate the conflict markers.
2.Manually edit the file to resolve the conflict by choosing or
combining the changes.
3.Stage the resolved files using:
git add <file>
4.Complete the merge or rebase with:
git commit (for merge).
git rebase --continue (for rebase).
5.Abort the Operation:
If the conflict cannot be resolved , the process can be aborted by:
git merge --abort
git rebase --abort
Co llab o rat in g w i t h
G i ta Repository: Team members can clone a shared
1.Cloning
remote repository to work on their local machines using:
git clone <repository-url>
2.Branching for Features: Developers can create separate
branches to work on new features or bug fixes without affecting
the main branch. Once done, the branch can be merged into the
main repository.
3.Pushing and Pulling Changes: Team members can push their
local commits to the remote repository for sharing their work and
pull updates from others using:
git push to upload changes.
git pull to fetch and integrate updates from the remote
repository.
4.Handling Pull Requests: On platforms like GitHub or GitLab,
developers can create pull requests to propose changes, review
code, and discuss before merging into the main branch
GIT HUB
• Web based platform for version control
• It hosts git repositories
• Facilitates team collaboration with tools like pull requests , etc .
• Tracks changes and enables roll back
• Open source : Anyone can contribute and learn from it
Conclusio
nBest Practices for Using Git
• Commit Frequently: Make small, incremental commits with
meaningful messages to keep the project history clean and
understandable.
• Use Branches: Create separate branches for new features, bug fixes,
or experiments to keep the main branch stable.
• Write Clear Commit Messages: Use descriptive commit messages to
explain what changes were made and why.
• Pull Regularly: Frequently pull changes from the remote repository
to avoid large, complex merges later on.
Thanks
!

You might also like