presents
Git Session
What is Git?
Git
- VCS (Version Control System)
- Helps to collaborate smoothly
- Easy to learn
- Lightning-fast performance.
What is GitHub?
GitHub
- Social networking site for developers
- What all can you do?
> show off your projects
> see other people’s code
> identify issues
> propose changes
- Get noticed by potential recruiters (◔◡◔)
Git
Vs
GitHub
Git GitHub
Git is a VCS GitHub is a hosting
(Version Control System) service for Git Repositories
Git is installed and GitHub is exclusively
maintained on your cloud-based, so that
local system you can share
(rather than in the cloud) your code with others
Go through below link once before starting with the installation
https://git-scm.com/book/en/v2/Getting-Started-Installing-Git INSTALLATION
LINUX
sudo apt-get install git
MACOS
brew install git
(install homebrew first)
WINDOWS
Follow below link -
https://git-scm.com/download/win
Okayyy
letss
goooo
FEW TERMINOLOGIES TO KNOW
REPOSITORY LOCAL REPO REMOTE REPO
A Git Repository
(or a repo) is a
folder that you’ve Repo stored on your Central repo from where
told Git to help you computer everyone pulls/pushes
changes
track your file
changes
OPEN SOURCE WORKFLOW
Clone/ Pull
Fork original Repo
Push
Pull Request
System GitHub Account and Original Repo
Forked Repo
TOO MUCH THEORY ( ͡ಥ ͜ʖ ͡ಥ)
LET’S GET SOME HANDS ON
git init
- Creates an empty Git repo
- Or make an existing folder as a Git
repo
- Creates a .git subdirectory
- It has all of the necessary information
identify the folder as a Git repo
git init
git status
- Checks the status of untracked files
from the repository
- These files can be added to our
repository
git status
git add
- Used to add files/ file contents from
the working tree to the staging area
- Prepares the staged content for the
next commit
git add <File name>
git add . or git add -A
git commit
- Records changes in the repository. (Each
commit has a unique ID to track it)
- Share these changes with the version
control system
- It saves “snapshots” of your project
- We can recall the commits or revert it to
the older version.
git commit -m "Commit message"
git remote
- Explicitly adds a remote repo for your
local repo.
- Enables you to pull/push changes from
the remote repo.
- Remote repo is stored on a code hosting
service like GitHub.
git remote add origin <url>
git push
- Transfer commits from your local repo to
a remote repo.
- Capable of overwriting changes.
git push origin master
WHERE CODE LIVES
add commit
WORKING WORKING
AREA STAGING
AREA VENUS
REPOSITORY
AREA
checkout branch
FORK VS CLONE
Central Repository Central Repository
(upstream) (upstream)
fork clone
Repository on
GitHub Local Computer
GIT FORK Central Repository
(upstream)
Forking is a concept while cloning is a
process. Fork Pull request
Your repo
Forking is done on the GitHub Account
while Cloning is done using Git.
Clone Push
Local Computer
Changes made to the forked repository
can be merged with the original repository
via a pull request.
Edits Edits
REMOTE vs UPSTREAM
Upstream generally refers to the original
repo that you have forked
Origin is your fork: your own
repo on GitHub,
git remote -v
git remote add <name> <url>
git remote rm <name>
git remote rename <old-name> <new-
name>
BRANCH
A branch is a version of the repository
that diverges from the main working
project.
The master branch is a
default branch in Git. It is
instantiated when first commit
made on the project. ,
git branch <branch>
git checkout <new_branch>
git branch
git branch -d <branch>
PULL REQUESTS
FETCH vs PULL
Fetch updates all the remote
tracking branches in local
repository.
PULL fetches (git fetch) the new
commits and merges (git
merge) these into your local branch.
git fetch <remote> <branch>
git fetch --all
git pull
git pull <remote>
MERGE CONFLICTS
SOLVED MERGE CONFLICTS 🥳
git log
- Git log is a flexible command which
allows users to view the history of the
repository.
- It has many flags which can modify
the format in which output is
displayed
- You can also filter which commits to
show.
git log
git rebase
- Git rebase is use to modify the commit
history.
- It helps us to maintain a clean commit
history.
- It replaces the existing commits with new
commits.
- It can be a destructive command which
can alter the history completely and should
be used carefully.
git rebase master
Rebase in action
MERGE vs REBASE
git merge adds a new merge
commit to the branch.
git rebase replaces the existing
commits with new commits
GitHub Student Developer Pack
Git the
ground
running!!
RESOURCES
● https://www.youtube.com/watch?v=w3jLJU7DT5E
● https://www.youtube.com/watch?v=hwP7WQkmECE
● https://www.youtube.com/watch?v=yySsukXlnzg&list=PLLt4yMoVgcz
VgFcTzT60U5IXtNX1qjHL9
● https://codeburst.io/git-and-github-in-a-nutshell-b0a3cc06458f
● https://frontendmasters.com/workshops/git-indepth/
THANKS!
Raina Jain
Ashlesha Dixit
Apoorve Shukla
Aditya Chhaparia