SlideShare a Scribd company logo
Git hub
Git - GitHub
Presented By:
Nitin Goel
About Git
• Created by Linus Torvalds, creator of Linux, in 2005
– Came out of Linux development community
– Designed to do version control on Linux kernel
• Goals of Git:
– Speed
– Support for non-linear development (thousands of parallel branches)
– Fully distributed
– Able to handle large projects efficiently
Centralized VCS
• In Subversion, CVS, Perforce, etc.
A central server repository (repo)
holds the "official copy" of the
code
• The server maintains the sole
version history of the repo
• You make "checkouts" of it to
your local copy
• You make local modifications
• Your changes are not versioned
• When you're done, you "check in"
back to the server
• Your check in increments the
repo's version
Distributed VCS (Git)
• In git, mercurial, etc., you don't
"checkout" from a central repo, you
"clone" it and "pull" changes from it
• Your local repo is a complete copy of
everything on the remote server
• Yours is "just as good" as theirs
• Many operations are local:
– check in/out from local repo
– commit changes to local repo
– local repo keeps version history
• When you're ready, you can "push"
changes back to server
Version Control
• Version control is a system that records changes to a file or set of files over
time so that you can recall specific versions later.
• Allows for collaborative development
• Allows you to know who made what changes and when
• Allows you to revert any changes and go back to a previous state
• Three of the most popular version control systems are:
 Git
 Subversion
 Mercurial
Git vs Github
• Git is a revision control system, a tool to manage your source code history.
• Github is a hosting service for Git repositories.
Terminology
Version Control System / Source Code Manager
 A version control system (abbreviated as VCS) is a tool that manages different versions of
source code. A source code manager (abbreviated as SCM) is another name for a version
control system.
Commit
 Git thinks of its data like a set of snapshots of a mini file system. Every time you commit (save
the state of your project in Git), it basically takes a picture of what all your files look like at
that moment and stores a reference to that snapshot. You can think of it as a save point in a
game - it saves your project's files and any information about them.
Repository / repo
 A repository is a directory which contains your project work, as well as a few files (hidden by
default on Mac OS X) which are used to communicate with Git. Repositories can exist either
locally on your computer or as a remote copy on another computer. A repository is made up
of commits.
Terminology
Working Directory
 The Working Directory is the files that you see in your computer's file system. When you open your project files up
on a code editor, you're working with files in the Working Directory.
 This is in contrast to the files that have been saved (in commits!) in the repository.
Checkout
 A checkout is when content in the repository has been copied to the Working Directory.
Staging Area / Staging Index / Index
 A file in the Git directory that stores information about what will go into your next commit. You can think of the staging area as a prep
table where Git will take the next commit. Files on the Staging Index are poised to be added to the repository.
SHA(Secure Hash Algorithm)
 A SHA is basically an ID number for each commit. Here's what a commit's SHA might look
like: e2adf8ae3e2e4ed40add75cc44cf9d0a869afeb6.
Branch
 A branch is when a new line of development is created that diverges from the main line of development. This
alternative line of development can continue without altering the main line.
Install Git on Windows
• Download the latest Git for windows installer.
• When you've successfully started the installer, you should see the Git
Setup wizard screen. Follow the Next and Finish prompts to complete the
installation.
• Open a Command Prompt (or Git Bash if during installation you elected
not to use Git from the Windows Command Prompt).
• Run the following commands to configure your Git. These details will be
associated with any commits that you create.
Git Configuration
• # sets up Git with your name
git config --global user.name "<Your-Full-Name>"
• # sets up Git with your email
git config --global user.email "<your-email-address>"
• # makes sure that Git output is colored
git config --global color.ui auto
• # displays the original state in a conflict
git config --global merge.conflictstyle diff3
• git config --list
Associating text editors with Git
• Using Atom as your editor
– Install Atom.
– Open Git Bash.
– Type this command:
git config --global core.editor
“C:/Users/USERNAME/AppData/Local/atom/bin/atom.cmd”
Using Sublime Text as your editor
– Install Sublime Text 3.
– Open Git Bash.
– Type this command:
git config --global core.editor "'c:/program files/sublime text 3/subl.exe'
-w"
• Using Notepad++ as your editor
– Install Notepad++.
– Open Git Bash.
– Type this command:
git config --global core.editor "'C:/Program Files
(x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -
noPlugin"
git init
• Running the git init command sets up all of the necessary files and
directories that Git will use to keep track of everything.
• All of these files are stored in a directory called .git (notice the . at the
beginning - that means it'll be a hidden directory on Mac/Linux).
• This .git directory is the "repo"! This is where git records all of the commits
and keeps track of everything!
Local git areas
Git hub
git clone
• The git clone command is used to create an identical copy of an existing
repository.
$ git clone <path-to-repository-to-clone>
This command:
 takes the path to an existing repository
 by default will create a directory with the same name as the repository that's being
cloned
 can be given a second argument that will be used as the name of the directory
 will create the new repository inside of the current working directory
git status
• The git status command displays the state of the working directory and the staging
area.
• It lets you see which changes have been staged, which haven’t, and which files
aren’t being tracked by Git.
• Status output does not show you any information regarding the committed project
history.
Git hub
git log
• The git log command is used to display all of the commits of a repository.
• By default, this command displays:
 the SHA
 the author
 the date
 and the message
git add
The git add command is used to move files from the Working Directory to the Staging Index.
$ git add <file1> <file2> … <fileN>
This command:
• takes a space-separated list of file names
• alternatively, the period . can be used in place of a list of files to tell Git to add the current
directory (and all nested files)
• git rm --cached <file> command can be used to remove a file from staging Index. This
command will not destroy any of your work, it just removes it from the Staging Index.
git commit
The git commit command takes files from the Staging Index and saves them in
the repository.
$ git commit
This command:
• will open the code editor that is specified in your configuration
• (check out the Git configuration step from the first lesson to configure
your editor)
• Inside the code editor:
– a commit message must be supplied
– lines that start with a # are comments and will not be recorded
– save the file after adding a commit message
– close the editor to make the commit
Then, use git log to review the commit you just made!
Git hub
Commit message
Do
• do keep the message short (less than 60-ish characters)
• do explain what the commit does (not how or why!)
Do not
• do not explain why the changes are made (more on this below)
• do not explain how the changes are made (that's what git log -p is for!)
• do not use the word "and"
• if you have to use "and", your commit message is probably doing too many
changes - break the changes into separate commits
• e.g. "make the background color pink and increase the size of the sidebar"
git log --oneline
• This command shortens the SHA and commit message to just one line
• Q key is pressed to co come out to regular command prompt
git log --stat
 displays the file(s) that have been modified
 displays the number of lines that have been added/removed
 displays a summary line with the total number of modified files and lines
that have been added/removed
git log –p or git log --patch
This command adds the following to the default output:
 displays the files that have been modified
 displays the location of the lines that have been added/removed
 displays the actual changes that have been made
git show
The git show command will show only one commit.
By default, git show displays:
the commit
the author
the date
the commit message
the patch information
git diff
git diff command is used to see changes that have been made but haven't
been committed, yet:
$ git diff
This command displays:
• the files that have been modified
• the location of the lines that have been added/removed
• the actual changes that have been made
Git hub
git ignore
• Git sees every file in your working copy as one of three things:
– tracked - a file which has been previously staged or committed;
– untracked - a file which has not been staged or committed; or
– ignored - a file which Git has been explicitly told to ignore.
– Ignored files are usually build artifacts and machine generated files
that can be derived from your repository source or should otherwise
not be committed. Some common examples are:
 compiled code, such as .o, .pyc, and .class files
 build output directories, such as /bin, /out, or /target
 files generated at runtime, such as .log, .lock, or .tmp
 hidden system files, such as .DS_Store or Thumbs.db
git tag
• Git has the ability to tag specific points in history as being important.
• Git supports two types of tags: lightweight and annotated.
 A lightweight tag is very much like a branch that doesn’t change — it’s
just a pointer to a specific commit.
git tag v1.0
 Annotated tags are stored as full objects in the Git database. They’re
checksummed; contain the tagger name, email, and date; have a
tagging message; and can be signed and verified with GNU Privacy
Guard (GPG).
git tag -a v1.0 -m “Insert message.“
 To delete tag
git –d v1.0 or git --delete v1.0
git branch
• Branch enables programmer to work in the same project in different
isolated environments.
• When it is required to add a new feature or fix a bug—no matter how big
or how small ,a new branch can be created to encapsulate the changes.
Commands
• git branch list all of the branches in your repository.
• git branch <branch> create a new branch called <branch>. This
does not check out the new branch.
• git branch -d <branch> delete the specified branch. This is a “safe”
operation in that Git prevents you from deleting the branch if it has
unmerged changes.
• git branch -D <branch> force delete the specified branch, even if it has
unmerged changes.
• git branch -m <branch> rename the current branch to <branch>.
• git checkout <branch> checkout to branch called <branch>.
• git checkout –b <branch> create a new branch called <branch> and
checkout simultaneously.
git merge
The git merge command lets you take the independent lines of development
created by git branch and integrate them into a single branch.
git merge <branch>
There are two types of merging:
1. Fast forward merge
2. 3-way merge.
Fast forward merge
• A fast-forward merge can occur when there is a linear path from the
current branch tip to the target branch.
• Before merge:
• After merge:
3-way merge
• A fast-forward merge is not possible if the branches have diverged. When
there is not a linear path to the target branch, Git has no choice but to
combine them via a 3-way merge. 3-way merges use a dedicated commit
to tie together the two histories.
Git hub
• Before Merge
• After Merge
Merge conflict
• If the two branches you're trying to merge both changed the same part of
the same file, Git won't be able to figure out which version to use. When
such a situation occurs, it stops right before the merge commit so that you
can resolve the conflicts manually.
• visual markers to represent conflict are: <<<<<<<, =======, and >>>>>>>.
--amend
• Git commit –amend command is used to edit most recent commit.
git commit --amend
• Steps involved are:
– edit the file(s)
– save the file(s)
– stage the file(s)
– and run git commit --amend
git revert
The git revert command is used to reverse a previously made commit:
$ git revert <SHA-of-commit-to-revert>
This command:
 will undo the changes that were made by the provided commit
 creates a new commit to record the change
git reset
• git reset --option <SHA> command is used to erase commits. There are
three options to reset.
1. –soft (erased commits shifts to staging index)
2. –mixed(default and (erased commits shifts to working directory)
3. –hard(erases directly)
Remote repositry
• A remote repository is the same Git repository like yours but it exists
somewhere else.
• Remotes can be accessed in a couple of ways:
– with a URL
– path to a file system
• we can interact and control a remote repository is through the Git remote
command:
– $ git remote
git push
• Create a new repository on GitHub. To avoid errors, do not initialize the
new repository with README, license, or .gitignore files. You can add
these files after your project has been pushed to GitHub.
• Open Git Bash.
• Change the current working directory to your local project.
• Initialize the local directory as a Git repository.
– git init
• Add the files in your new local repository. This stages them for the first
commit.
– git add .
• Commit the files that you've staged in your local repository.
– git commit -m "First commit"
• Copy remote repository URL field at the top of your GitHub repository's
Quick Setup page, click to copy the remote repository URL.
• In the Command prompt, add the URL for the remote repository where
your local repository will be pushed.
-git remote add origin remote repository URL
• git remote –v command verifies the new remote URL
• Push the changes in your local repository to GitHub.
-git push origin master
# Pushes the changes in your local repository up to the remote repository you
specified as the origin
git fetch or git pull
• The git fetch command downloads commits, files, and refs from a remote
repository into your local repo. Git isolates fetched content as a from
existing local content, it has absolutely no effect on your local
development work.
– git push origin master
– git fetch origin master
• This makes fetching a safe way to review commits before integrating them
with your local repository.
• git fetch is the 'safe' version of the two commands. It will download the
remote content but not update your local repo's working state, leaving
your current work intact. git pull is the more aggressive alternative, it will
download the remote content for the active local branch and immediately
execute git merge to create a merge commit for the new remote content.
Thank You

More Related Content

What's hot (20)

PPTX
Introduction to Git and GitHub Part 1
Omar Fathy
 
PDF
Git and github 101
Senthilkumar Gopal
 
PDF
Git basics
GHARSALLAH Mohamed
 
PDF
Introduction to Git
Yan Vugenfirer
 
PDF
Intro to Git and GitHub
Panagiotis Papadopoulos
 
PPTX
Source control
Sachithra Gayan
 
PPTX
Git Pull Requests
Callon Campbell
 
KEY
Git and GitHub
James Gray
 
PDF
Starting with Git & GitHub
Nicolás Tourné
 
PDF
Git and GitHub for Documentation
Anne Gentle
 
PPTX
Grokking opensource with github
GoogleDeveloperStude4
 
PPTX
Github
MeetPatel710
 
PDF
Git - An Introduction
Behzad Altaf
 
PPTX
Introduction to Git and GitHub
Bioinformatics and Computational Biosciences Branch
 
PDF
Git-flow workflow and pull-requests
Bartosz Kosarzycki
 
PPTX
Git and git hub basics
prostackacademy
 
PPT
Git vs SVN
neuros
 
PPTX
GitHub Presentation
BrianSchilder
 
PPTX
GIT INTRODUCTION
MohanRaviRohitth
 
PDF
Learning git
Sid Anand
 
Introduction to Git and GitHub Part 1
Omar Fathy
 
Git and github 101
Senthilkumar Gopal
 
Git basics
GHARSALLAH Mohamed
 
Introduction to Git
Yan Vugenfirer
 
Intro to Git and GitHub
Panagiotis Papadopoulos
 
Source control
Sachithra Gayan
 
Git Pull Requests
Callon Campbell
 
Git and GitHub
James Gray
 
Starting with Git & GitHub
Nicolás Tourné
 
Git and GitHub for Documentation
Anne Gentle
 
Grokking opensource with github
GoogleDeveloperStude4
 
Github
MeetPatel710
 
Git - An Introduction
Behzad Altaf
 
Git-flow workflow and pull-requests
Bartosz Kosarzycki
 
Git and git hub basics
prostackacademy
 
Git vs SVN
neuros
 
GitHub Presentation
BrianSchilder
 
GIT INTRODUCTION
MohanRaviRohitth
 
Learning git
Sid Anand
 

Similar to Git hub (20)

PPTX
Git Basics for Software Version Management
ishanmittal49
 
PDF
git.ppt.pdf
Roniel Lopez Alvarez
 
PPTX
Git walkthrough
Bimal Jain
 
PPTX
1-Intro to VC & GIT PDF.pptx
HuthaifaAlmaqrami1
 
PPTX
github ppt git ppt on git hub to know ab
infoinnext
 
PPTX
Git 101
jayrparro
 
PPTX
GIT.pptx
Soumen Debgupta
 
PPT
Learn Git Basics
Prakash Dantuluri
 
PPT
Git installation and configuration
Kishor Kumar
 
PPTX
Introduction to git and githhub with practicals.pptx
Abdul Salam
 
PPTX
Introduction to git hub
Naveen Pandey
 
PPT
Git introduction
satyendrajaladi
 
PPTX
Introduction to Git and Github
Max Claus Nunes
 
PDF
Source Code Management with Git
Things Lab
 
PPTX
git.ppt.pptx power point presentation got Google internet
rani marri
 
PPT
CSE 390 Lecture 9 - Version Control with GIT
PouriaQashqai1
 
PPTX
IS - section 1 - modifiedFinal information system.pptx
NaglaaAbdelhady
 
PPT
Git 101 - Crash Course in Version Control using Git
Geoff Hoffman
 
PDF
Git for developers
Hacen Dadda
 
PPTX
git and github-1.pptx
tnscharishma
 
Git Basics for Software Version Management
ishanmittal49
 
Git walkthrough
Bimal Jain
 
1-Intro to VC & GIT PDF.pptx
HuthaifaAlmaqrami1
 
github ppt git ppt on git hub to know ab
infoinnext
 
Git 101
jayrparro
 
GIT.pptx
Soumen Debgupta
 
Learn Git Basics
Prakash Dantuluri
 
Git installation and configuration
Kishor Kumar
 
Introduction to git and githhub with practicals.pptx
Abdul Salam
 
Introduction to git hub
Naveen Pandey
 
Git introduction
satyendrajaladi
 
Introduction to Git and Github
Max Claus Nunes
 
Source Code Management with Git
Things Lab
 
git.ppt.pptx power point presentation got Google internet
rani marri
 
CSE 390 Lecture 9 - Version Control with GIT
PouriaQashqai1
 
IS - section 1 - modifiedFinal information system.pptx
NaglaaAbdelhady
 
Git 101 - Crash Course in Version Control using Git
Geoff Hoffman
 
Git for developers
Hacen Dadda
 
git and github-1.pptx
tnscharishma
 
Ad

Recently uploaded (20)

DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
DOCX
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PDF
Tips for Writing the Research Title with Examples
Thelma Villaflores
 
PPTX
Electrophysiology_of_Heart. Electrophysiology studies in Cardiovascular syste...
Rajshri Ghogare
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PPTX
The Future of Artificial Intelligence Opportunities and Risks Ahead
vaghelajayendra784
 
PPTX
Top 10 AI Tools, Like ChatGPT. You Must Learn In 2025
Digilearnings
 
PPTX
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PPTX
YSPH VMOC Special Report - Measles Outbreak Southwest US 7-20-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PPTX
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
PPTX
Cybersecurity: How to Protect your Digital World from Hackers
vaidikpanda4
 
PDF
John Keats introduction and list of his important works
vatsalacpr
 
PPTX
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Tips for Writing the Research Title with Examples
Thelma Villaflores
 
Electrophysiology_of_Heart. Electrophysiology studies in Cardiovascular syste...
Rajshri Ghogare
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
The Future of Artificial Intelligence Opportunities and Risks Ahead
vaghelajayendra784
 
Top 10 AI Tools, Like ChatGPT. You Must Learn In 2025
Digilearnings
 
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 7-20-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
Cybersecurity: How to Protect your Digital World from Hackers
vaidikpanda4
 
John Keats introduction and list of his important works
vatsalacpr
 
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
Basics and rules of probability with real-life uses
ravatkaran694
 
Ad

Git hub

  • 2. Git - GitHub Presented By: Nitin Goel
  • 3. About Git • Created by Linus Torvalds, creator of Linux, in 2005 – Came out of Linux development community – Designed to do version control on Linux kernel • Goals of Git: – Speed – Support for non-linear development (thousands of parallel branches) – Fully distributed – Able to handle large projects efficiently
  • 4. Centralized VCS • In Subversion, CVS, Perforce, etc. A central server repository (repo) holds the "official copy" of the code • The server maintains the sole version history of the repo • You make "checkouts" of it to your local copy • You make local modifications • Your changes are not versioned • When you're done, you "check in" back to the server • Your check in increments the repo's version
  • 5. Distributed VCS (Git) • In git, mercurial, etc., you don't "checkout" from a central repo, you "clone" it and "pull" changes from it • Your local repo is a complete copy of everything on the remote server • Yours is "just as good" as theirs • Many operations are local: – check in/out from local repo – commit changes to local repo – local repo keeps version history • When you're ready, you can "push" changes back to server
  • 6. Version Control • Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. • Allows for collaborative development • Allows you to know who made what changes and when • Allows you to revert any changes and go back to a previous state • Three of the most popular version control systems are:  Git  Subversion  Mercurial
  • 7. Git vs Github • Git is a revision control system, a tool to manage your source code history. • Github is a hosting service for Git repositories.
  • 8. Terminology Version Control System / Source Code Manager  A version control system (abbreviated as VCS) is a tool that manages different versions of source code. A source code manager (abbreviated as SCM) is another name for a version control system. Commit  Git thinks of its data like a set of snapshots of a mini file system. Every time you commit (save the state of your project in Git), it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. You can think of it as a save point in a game - it saves your project's files and any information about them. Repository / repo  A repository is a directory which contains your project work, as well as a few files (hidden by default on Mac OS X) which are used to communicate with Git. Repositories can exist either locally on your computer or as a remote copy on another computer. A repository is made up of commits.
  • 9. Terminology Working Directory  The Working Directory is the files that you see in your computer's file system. When you open your project files up on a code editor, you're working with files in the Working Directory.  This is in contrast to the files that have been saved (in commits!) in the repository. Checkout  A checkout is when content in the repository has been copied to the Working Directory. Staging Area / Staging Index / Index  A file in the Git directory that stores information about what will go into your next commit. You can think of the staging area as a prep table where Git will take the next commit. Files on the Staging Index are poised to be added to the repository. SHA(Secure Hash Algorithm)  A SHA is basically an ID number for each commit. Here's what a commit's SHA might look like: e2adf8ae3e2e4ed40add75cc44cf9d0a869afeb6. Branch  A branch is when a new line of development is created that diverges from the main line of development. This alternative line of development can continue without altering the main line.
  • 10. Install Git on Windows • Download the latest Git for windows installer. • When you've successfully started the installer, you should see the Git Setup wizard screen. Follow the Next and Finish prompts to complete the installation. • Open a Command Prompt (or Git Bash if during installation you elected not to use Git from the Windows Command Prompt). • Run the following commands to configure your Git. These details will be associated with any commits that you create.
  • 11. Git Configuration • # sets up Git with your name git config --global user.name "<Your-Full-Name>" • # sets up Git with your email git config --global user.email "<your-email-address>" • # makes sure that Git output is colored git config --global color.ui auto • # displays the original state in a conflict git config --global merge.conflictstyle diff3 • git config --list
  • 12. Associating text editors with Git • Using Atom as your editor – Install Atom. – Open Git Bash. – Type this command: git config --global core.editor “C:/Users/USERNAME/AppData/Local/atom/bin/atom.cmd” Using Sublime Text as your editor – Install Sublime Text 3. – Open Git Bash. – Type this command: git config --global core.editor "'c:/program files/sublime text 3/subl.exe' -w"
  • 13. • Using Notepad++ as your editor – Install Notepad++. – Open Git Bash. – Type this command: git config --global core.editor "'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession - noPlugin"
  • 14. git init • Running the git init command sets up all of the necessary files and directories that Git will use to keep track of everything. • All of these files are stored in a directory called .git (notice the . at the beginning - that means it'll be a hidden directory on Mac/Linux). • This .git directory is the "repo"! This is where git records all of the commits and keeps track of everything!
  • 17. git clone • The git clone command is used to create an identical copy of an existing repository. $ git clone <path-to-repository-to-clone> This command:  takes the path to an existing repository  by default will create a directory with the same name as the repository that's being cloned  can be given a second argument that will be used as the name of the directory  will create the new repository inside of the current working directory
  • 18. git status • The git status command displays the state of the working directory and the staging area. • It lets you see which changes have been staged, which haven’t, and which files aren’t being tracked by Git. • Status output does not show you any information regarding the committed project history.
  • 20. git log • The git log command is used to display all of the commits of a repository. • By default, this command displays:  the SHA  the author  the date  and the message
  • 21. git add The git add command is used to move files from the Working Directory to the Staging Index. $ git add <file1> <file2> … <fileN> This command: • takes a space-separated list of file names • alternatively, the period . can be used in place of a list of files to tell Git to add the current directory (and all nested files) • git rm --cached <file> command can be used to remove a file from staging Index. This command will not destroy any of your work, it just removes it from the Staging Index.
  • 22. git commit The git commit command takes files from the Staging Index and saves them in the repository. $ git commit This command: • will open the code editor that is specified in your configuration • (check out the Git configuration step from the first lesson to configure your editor) • Inside the code editor: – a commit message must be supplied – lines that start with a # are comments and will not be recorded – save the file after adding a commit message – close the editor to make the commit Then, use git log to review the commit you just made!
  • 24. Commit message Do • do keep the message short (less than 60-ish characters) • do explain what the commit does (not how or why!) Do not • do not explain why the changes are made (more on this below) • do not explain how the changes are made (that's what git log -p is for!) • do not use the word "and" • if you have to use "and", your commit message is probably doing too many changes - break the changes into separate commits • e.g. "make the background color pink and increase the size of the sidebar"
  • 25. git log --oneline • This command shortens the SHA and commit message to just one line • Q key is pressed to co come out to regular command prompt
  • 26. git log --stat  displays the file(s) that have been modified  displays the number of lines that have been added/removed  displays a summary line with the total number of modified files and lines that have been added/removed
  • 27. git log –p or git log --patch This command adds the following to the default output:  displays the files that have been modified  displays the location of the lines that have been added/removed  displays the actual changes that have been made
  • 28. git show The git show command will show only one commit. By default, git show displays: the commit the author the date the commit message the patch information
  • 29. git diff git diff command is used to see changes that have been made but haven't been committed, yet: $ git diff This command displays: • the files that have been modified • the location of the lines that have been added/removed • the actual changes that have been made
  • 31. git ignore • Git sees every file in your working copy as one of three things: – tracked - a file which has been previously staged or committed; – untracked - a file which has not been staged or committed; or – ignored - a file which Git has been explicitly told to ignore. – Ignored files are usually build artifacts and machine generated files that can be derived from your repository source or should otherwise not be committed. Some common examples are:  compiled code, such as .o, .pyc, and .class files  build output directories, such as /bin, /out, or /target  files generated at runtime, such as .log, .lock, or .tmp  hidden system files, such as .DS_Store or Thumbs.db
  • 32. git tag • Git has the ability to tag specific points in history as being important. • Git supports two types of tags: lightweight and annotated.  A lightweight tag is very much like a branch that doesn’t change — it’s just a pointer to a specific commit. git tag v1.0  Annotated tags are stored as full objects in the Git database. They’re checksummed; contain the tagger name, email, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG). git tag -a v1.0 -m “Insert message.“  To delete tag git –d v1.0 or git --delete v1.0
  • 33. git branch • Branch enables programmer to work in the same project in different isolated environments. • When it is required to add a new feature or fix a bug—no matter how big or how small ,a new branch can be created to encapsulate the changes.
  • 34. Commands • git branch list all of the branches in your repository. • git branch <branch> create a new branch called <branch>. This does not check out the new branch. • git branch -d <branch> delete the specified branch. This is a “safe” operation in that Git prevents you from deleting the branch if it has unmerged changes. • git branch -D <branch> force delete the specified branch, even if it has unmerged changes. • git branch -m <branch> rename the current branch to <branch>. • git checkout <branch> checkout to branch called <branch>. • git checkout –b <branch> create a new branch called <branch> and checkout simultaneously.
  • 35. git merge The git merge command lets you take the independent lines of development created by git branch and integrate them into a single branch. git merge <branch> There are two types of merging: 1. Fast forward merge 2. 3-way merge.
  • 36. Fast forward merge • A fast-forward merge can occur when there is a linear path from the current branch tip to the target branch.
  • 37. • Before merge: • After merge:
  • 38. 3-way merge • A fast-forward merge is not possible if the branches have diverged. When there is not a linear path to the target branch, Git has no choice but to combine them via a 3-way merge. 3-way merges use a dedicated commit to tie together the two histories.
  • 40. • Before Merge • After Merge
  • 41. Merge conflict • If the two branches you're trying to merge both changed the same part of the same file, Git won't be able to figure out which version to use. When such a situation occurs, it stops right before the merge commit so that you can resolve the conflicts manually. • visual markers to represent conflict are: <<<<<<<, =======, and >>>>>>>.
  • 42. --amend • Git commit –amend command is used to edit most recent commit. git commit --amend • Steps involved are: – edit the file(s) – save the file(s) – stage the file(s) – and run git commit --amend
  • 43. git revert The git revert command is used to reverse a previously made commit: $ git revert <SHA-of-commit-to-revert> This command:  will undo the changes that were made by the provided commit  creates a new commit to record the change
  • 44. git reset • git reset --option <SHA> command is used to erase commits. There are three options to reset. 1. –soft (erased commits shifts to staging index) 2. –mixed(default and (erased commits shifts to working directory) 3. –hard(erases directly)
  • 45. Remote repositry • A remote repository is the same Git repository like yours but it exists somewhere else. • Remotes can be accessed in a couple of ways: – with a URL – path to a file system • we can interact and control a remote repository is through the Git remote command: – $ git remote
  • 46. git push • Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or .gitignore files. You can add these files after your project has been pushed to GitHub. • Open Git Bash. • Change the current working directory to your local project. • Initialize the local directory as a Git repository. – git init • Add the files in your new local repository. This stages them for the first commit. – git add . • Commit the files that you've staged in your local repository. – git commit -m "First commit"
  • 47. • Copy remote repository URL field at the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL. • In the Command prompt, add the URL for the remote repository where your local repository will be pushed. -git remote add origin remote repository URL • git remote –v command verifies the new remote URL • Push the changes in your local repository to GitHub. -git push origin master # Pushes the changes in your local repository up to the remote repository you specified as the origin
  • 48. git fetch or git pull • The git fetch command downloads commits, files, and refs from a remote repository into your local repo. Git isolates fetched content as a from existing local content, it has absolutely no effect on your local development work. – git push origin master – git fetch origin master • This makes fetching a safe way to review commits before integrating them with your local repository. • git fetch is the 'safe' version of the two commands. It will download the remote content but not update your local repo's working state, leaving your current work intact. git pull is the more aggressive alternative, it will download the remote content for the active local branch and immediately execute git merge to create a merge commit for the new remote content.