0% found this document useful (0 votes)
17 views38 pages

GITHUB

Git is a distributed version control system that enables collaboration on projects by tracking changes and facilitating branching and merging. GitHub is a cloud-based platform that uses Git for code management and collaboration, allowing developers to store and manage their code. The document outlines key Git commands, workflows, and best practices for effective version control and collaboration.

Uploaded by

ishan kumar
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)
17 views38 pages

GITHUB

Git is a distributed version control system that enables collaboration on projects by tracking changes and facilitating branching and merging. GitHub is a cloud-based platform that uses Git for code management and collaboration, allowing developers to store and manage their code. The document outlines key Git commands, workflows, and best practices for effective version control and collaboration.

Uploaded by

ishan kumar
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/ 38

GIT

AND
GITHUB
WHAT IS GIT?
Git is a distributed version control
system that allows multiple people to
collaborate on a project. It tracks
changes to files, allows for easy
branching and merging, and provides a
complete history of all changes made.
BENEFITS OF GIT
Using Git has several advantages. It
provides a backup of your code,
facilitates collaboration among
team members, allows for easy
experimentation with different
versions, and helps in debugging
and troubleshooting.
USING GITHUB WITH GIT

Git allows multiple developers to


work on the same project
simultaneously. By utilizing
branches and merging, conflicts
can be resolved and changes can
be integrated seamlessly.
What is Github?
GitHub, Inc. is a platform and cloud-
based service for software
development and version control
using Git, allowing developers to
store and manage their code.
Github in a
sentence...
GIT REMOTE
REPOSITORIES

Git supports remote repositories,


which can be hosted on
platforms like GitHub or GitLab.
Remote repositories allow for
easy sharing, backup, and
collaboration with others.
GIT WORKFLOW
The typical Git workflow involves
creating a repository, making
changes to files, staging those
changes, committing them, and
then pushing the changes to a
remote repository. This cycle of
making changes, staging, and
committing is repeated as
needed.
COMMON GIT COMMANDS

Git provides a set of


commands to perform
various operations. Some
common commands
include git init, git add, git
commit, git push, git pull,
git branch, git merge, and
git log.
Git Clone
The git clone command is
used to create a copy of a
specific repository or
branch within a repository.
CLONE A SPECIFIC BRANCH

git clone --branch <branchname> <remote-repo-url>


Git Fork

A fork is a new repository that shares code and


visibility settings with the original “upstream”
repository. Forks are often used to iterate on ideas or
changes before they are proposed back to the
upstream repository, such as in open source projects
or when a user does not have write access to the
upstream repository.
Git Add
Add changes or new files to the staging
area before committing them.
Git Status
Check the status of your repository and see which
files are modified.
Git commit
Git commit -m
Record changes to the
repository with a
descriptive commit
message.

Git commit -am


This adds all the changes
to your staging area and
commits them at the
same time .
Git log
Get details of you commit history with other details
LINKING LOCAL REPO TO A
REMOTE REPO
git remote add <alias> <URL>
This links the local repos on our systems to to the
remotes repo on GitHub.
Git Push

Upload local repository changes to


a remote repository.

git push REMOTE-NAME BRANCH-NAME


Never do this
Git Pull
git pull REMOTE-NAME BRANCH-NAME

Fetch and merge


changes from a
remote repository to
your local repository.
Branching in Git
Git allows for easy
branching, which enables
developers to work on
different features or bug
fixes simultaneously.
Each branch can be
merged back into the
main branch once the
changes are complete
and tested.
Git Branch Management
Managing branches in Git
is
crucial for organizing
work.
You can create new
branches,
switch between branches,
delete branches, and
rename branches to keep
your project structured.
Git Branch
Create, list, or delete
branches in your
repository

List branches with git branch


Create a branch with git branch <branch_name>
Delete a branch with git branch -D <branch-name>
Git Checkout

Switch between different


branches or restore files
from a specific commit.
Git Merge

Combine changes from


different branches into
the current branch.
Git Fetch

Download changes from a


remote repository
without merging them.
GIT INIT

The "git init" command is


used to create a new Git
repository in the current
directory. It initializes a new
empty repository and
creates a .git directory
where all the repository
data will be stored.
BEHIND THE SCENES
GIT BEST PRACTICES

Following best practices in Git can help


maintain a clean and efficient workflow.
Some practices include creating
meaningful commit messages, regularly
pulling changes from remote, and
keeping branches updated.
GIT MERGE CONFLICTS
When merging branches,
conflicts may arise if the
same file is modified in
different branches. Git
provides tools to resolve
these conflicts manually,
ensuring that changes are
integrated correctly.
NEVER DO THIS!!!
Undoing Changes in Git
Git provides options to undo
changes made to files. You can use
git checkout to discard changes in a
file, git reset to unstage changes, HEAD HEAD

and git revert to undo a commit. master master

HEAD HEAD

master master
Git Reset
Undo commits or unstage
changes in your
repository.
Git Reset and Revert
Git Stash
Sometimes you want to switch the branches, but you are
working on an incomplete part of your current project. You
don't want to make a commit of half-done work. Git stashing
allows you to do so. The git stash command enables you to
switch branches without committing the current branch.

git stash

You should commit all of your current


changes before switching branches.
Git Stash Pop
The git stash pop command lets a developer move their
most recently shelved changes into their working directory,
and also delete that popped stash upon command
completion. However, you must first add items to Git's stash
to pop your shelved changes out of it.

git stash pop

You might also like