SlideShare a Scribd company logo
Start slc
Salt Lake City, UT
January 31st, 2015
Intro to git
PRESENTED
BY
Nina Zakharenko
AND
PART 1
Overview
WHY
USE VERSION CONTROL
COMMITTING
TO YOUR REPOSITORY
GIT
IS NOT GITHUB
REPOSITORY
CREATE YOUR FIRST GIT PROJECT
PART 2
OVERVIEW
FINAL EXERCISEFORKING
(IS NOT A DIRTY WORD)
BRANCHES PULL REQUESTS
SHARING YOUR WORK
?
WHY USE VERSION CONTROL
Have you ever found
yourself creating multiple
versions of a file to “save”
your changes?
!
Do you make multiple
copies of files to make sure
you have a working
backup?
VERSION PROBLEMS
AND VERSIONS ARE ALL OF THEM.
I GOT 99 PROBLEMS
Version Control lets you maintain a history of your files.
!
This history is easily browsed, attached to author names, and logged
with extra commit information.
!
This is especially useful when working in a team environment.
VERSION CONTROL
Git is a tool.
!
More specifically, it’s an open source
distributed version control system with
an emphasis on data integrity and
speed.
GIT IS NOT GITHUB
GIT
github.com is a commercial website
that allows you to host git repositories
!
You can use it to find many open
source projects, and even share your
own.
GIT HUB
You might hear these terms used interchangeably.
They’re not the same!
OUR FIRST repo
LINGO
REPOSITORY
Local Repository - Where code is stored on your local machine
!
Remote Repository - Where code is stored on a remote server
(github, or internal server)
!
Git stores information about the repository in a hidden .git
directory contained in the same folder as the project.
!
Will be commonly referred to as a repo.
!
!
LINGO
CLONE
Copying a github repository to your local machine.
Let’s configure git on our local computer.
!
Use the same email address that your github account is
associated with.
!
$ git config --global user.name "Your Name Here”
!
$ git config --global user.email "your_email@youremail.com"
!
SETTING UP GIT
SET UP
To set up a git repository locally, we navigate via the
command line to the root of our project directory, and
run the command:
!
$ git init
TWO WAYS TO CREATE A REPO
LOCALLY
Log in to your github account.
!
Next, click on the ‘plus’ icon on the right side of the
toolbar, then click new repository.
ON GITHUB
You skip a few setup steps by initializing on github.
GITHUB - CREATE NEW REPO
CLONING OUR NEW REPOSITORY
GET THE URL
CLONE THE PROJECT LOCALLY
EXERCISE
CREATE & CLONE A GITHUB REPO
Creating a fork of my repository will copy it over to your github account.
EXERCISE
1. GO TO GITHUB.COM
Click the plus button on the right hand side, then select new repository.
!
Be aware, public repos are visible on the internet.
2. CREATE A NEW REPOSITORY
Copy the clone URL, then type in :
!
$ git clone <copied_clone_url_here>
3. COPY THE REPO URL, GIT CLONE
COMMITTING
TO YOUR REPOSITORY
LINGO
GIT ADD
$ git add <filename>
!
Git does not automatically keep track of all the files in a project
directory.
!
Use git add to make it aware of a new file, or use git add on an
existing file to let git know you’ve made changes to it that you
want to keep.
LINGO
THE STAGING AREA
When you use $ git add on a file, it gets added to the staging
area.
!
The staging area contains snapshots of files that will be included
in the next commit.
STAGING AREA
Source: 	http://git-scm.com/book/en/v2/Getting-Started-Git-
Basics
LINGO
GIT STATUS
A git command that will give you a status update about your
repository.
!
This is the command I use the most in my day to day git usage.
!
LET’S TRY IT
LINGO
GIT COMMIT
Record a snapshot of the files in the staging area.
!
$ git commit -m “A commit message contains
helpful information”
!
Note: When we run a $ git status after a commit, we’ll see
a message that says “nothing to commit”
LINGO
GIT LOG
A way to see what changes were made, and by who.
!
$ git log	
!
Use $ git diff <filename> to show the difference between
the last checked in version of that file, and the modified file.
LINGO
DIFF
SIDENOTE
WHEN SHOULD I COMMIT MY CODE?
Don’t wait for your code to be a in a perfect state before
committing it.
!
You’ll get the best benefits by committing early & often.
EXERCISE
COMMIT A FILE TO OUR REPO
Using the command line, navigate to the repo directory.
EXERCISE
1. NAVIGATE TO THE REPO
Open the README.md file with your editor of choice. Make and save
changes.
2. MODIFY THE README
Run the command: $ git add README.md
3. ADD FILE TO STAGING AREA
Run the command: $ git status to ensure your file is actually in the staging
4. RUN GIT STATUS
Run the command: $ git commit -m “my commit message”
5. COMMIT YOUR CHANGES
BRANCHES
LINGO
MASTER BRANCH
The master branch is usually the “production ready” version of
your codebase.
!
That means that everything compiles, and all your tests pass. This
is the version that customers will see - even if the customer is just
you.
!
There is only one master branch, and generally code is not
committed directly to it.
LINGO
FEATURE BRANCHES
Branches are extremely useful when you want to work on
different features without interfering with a working copy of the
code.
!
When you’re done working on your feature branch, you can
merge it back into master.
!
If your repository is stored on a remote server, multiple
developers can work on the same branch.
BRANCHES VISUALIZED
source: http://git-scm.com/about
When you create a new branch, you’re automatically
switched to it.
!
$ git checkout -b my_branch_name
USING BRANCHES
CREATE A NEW BRANCH
$ git branch -a
SEE ALL AVAILABLE BRANCHES
$ git checkout my_other_branch
CHECKOUT A DIFFERENT BRANCH
MERGING BRANCHES
MERGE FEATURE BRANCH INTO MASTER
Once you’re satisfied with your feature branch, it’s time to merge
it back into master.
!
$ git checkout master
!
$ git merge my_feature_branch
!
EXERCISE
CREATE A FEATURE BRANCH
$ git checkout -b my_new_branch
EXERCISE
1. CREATE A NEW BRANCH
Review the previous exercise if you need hints.
2. COMMIT CHANGES
3. CHECKOUT MASTER
$ git checkout master
4. MERGE YOUR BRANCH
$ git merge my_new_branch
1
2
34
CREATE A BRANCH
GIT COMMIT
COMMIT TO STAGING
GIT ADD
ADD FILES TO STAGING AREA
WRITE CODE
HACK HACK HACK
5
GIT PUSH
PUSH CHANGES
UP TO REPOSITORY
GIT CHECKOUT -B
GIT WORKFLOW
QUESTIOnS?
COLLABORATING
WITH GITHUB
LINGO
FORK
Forking a repository on github will create a copy of that project
in your github account.
A copy that exists in your GitHub account and can be
used to submit pull requests (changes) to the maintainers
of the project.
FORKING VS CLONING
FORK
A copy that does not exist in your GitHub account, and
cannot change the remote repo unless the person who
cloned it is added as a collaborator on the project.
CLONE
LINGO
PUSH/PULL
PUSH:
Send a copy of the latest committed changes to the remote
server.
!
PULL:
Retrieve a copy of the latest committed changes from the remote
server.
!
Note: If you’re working on a branch with other people, always
run a pull command before getting started.
LINGO
PULL REQUEST
A pull request is a proposal made by you to a project maintainer
asking them to accept your changes to their code base.
!
The maintainer can review a diff of the changes you made.


They can also leave general and code-line specific comments.
FINAL EXERCISE
PULL REQUESTS
https://github.com/nnja/gdi-pull-requests
Creating a fork of my repository will copy it over to your github account.
FINAL EXERCISE - PT1
1. FORK MY REPOSITORY
Go to the github page of your forked copy of gdi-pull-requests.
!
Copy the repository URL, clone the project to your local machine.
2. CLONE YOUR FORKED REPOSITORY
https://github.com/nnja/gdi-pull-requests
git checkout -b <yourname>_branch
3. CREATE A FEATURE BRANCH
Change over to the repository directory.
!
Create a file called <yournamehere>.txt.
FINAL EXERCISE - PT2
4. CREATE A FILE WITH A FUN FACT ABOUT YOU
git add <yourname>.txt
git commit -m “here’s a fun fact about me!”
5. ADD, THEN COMMIT YOUR FILE
https://github.com/nnja/gdi-pull-requests
git push -u origin <yourname>_branch
6. PUSH YOUR BRANCH TO THE REMOTE REPO
FINAL EXERCISE - PT3
7. CREATE A PULL REQUEST
https://github.com/nnja/gdi-pull-requests
FIN
RESOURCES
!
The entire Pro Git e-book.
!
The definitive manual.
!
Dense, time consuming, but
chock full of information.
!
http://git-scm.com/
book/en/v2
!
Short, concise, and visual
guides on beginner to
advanced github topics.
!
https://
guides.github.com/
A 15 minute interactive tutorial.
Bonus: Works in your browser,
no setup required.
!
https://try.github.io/
levels/1/challenges/1
ADDITIONAL
TRY GIT PRO GIT GITHUB GUIDES
THANK YOU
INTRO TO GIT
@nnja
girldevelopit.com

More Related Content

PDF
Recovering From Git Mistakes - Nina Zakharenko
Nina Zakharenko
 
KEY
Matt Gauger - Git & Github web414 December 2010
Matt Gauger
 
KEY
Git Distributed Version Control System
Victor Wong
 
PDF
Github - Le Wagon Melbourne
Paal Ringstad
 
PDF
Git & GitHub for Beginners
Sébastien Saunier
 
PPTX
Intro to git and git hub
Venkat Malladi
 
PPTX
Github
JaneAlamAdnan
 
DOCX
Git github
Anurag Deb
 
Recovering From Git Mistakes - Nina Zakharenko
Nina Zakharenko
 
Matt Gauger - Git & Github web414 December 2010
Matt Gauger
 
Git Distributed Version Control System
Victor Wong
 
Github - Le Wagon Melbourne
Paal Ringstad
 
Git & GitHub for Beginners
Sébastien Saunier
 
Intro to git and git hub
Venkat Malladi
 
Git github
Anurag Deb
 

What's hot (20)

PPT
Git basic
Emran Ul Hadi
 
PPTX
Git and GitHub
Md. Ahsan Habib Nayan
 
PDF
Git basics for beginners
PravallikaTammisetty
 
PDF
Git and git hub
Sebastiaan Deckers
 
PPT
Open Source Collaboration With Git And Git Hub
Nick Quaranto
 
PPTX
Git
Shinu Suresh
 
PDF
Git Anti-Patterns - Extended Version With 28 Common Anti-Patterns) - SCTurkey...
Lemi Orhan Ergin
 
PPTX
GitFlow, SourceTree and GitLab
Shinu Suresh
 
PDF
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Atlassian
 
KEY
What's new and great in Rails 3 - Matt Gauger - Milwaukee Ruby Users Group De...
Matt Gauger
 
PDF
Git and Github workshop
Otto Kekäläinen
 
PDF
Git & Github for beginners
Paulo Henrique Nonaka
 
PPTX
Introduction To Git Workshop
themystic_ca
 
PDF
Git in a nutshell
Pranesh Vittal
 
KEY
Matt Gauger - Lamp vs. the world - MKE PHP Users Group - December 14, 2010
Matt Gauger
 
DOCX
Bitbucket
hariprasad1035
 
PDF
Git & Github Workshop - Le Wagon Melbourne
Paal Ringstad
 
PDF
Advanced Git Tutorial
Sage Sharp
 
KEY
Gittalk
prtinsley
 
KEY
The everyday developer's guide to version control with Git
E Carter
 
Git basic
Emran Ul Hadi
 
Git and GitHub
Md. Ahsan Habib Nayan
 
Git basics for beginners
PravallikaTammisetty
 
Git and git hub
Sebastiaan Deckers
 
Open Source Collaboration With Git And Git Hub
Nick Quaranto
 
Git Anti-Patterns - Extended Version With 28 Common Anti-Patterns) - SCTurkey...
Lemi Orhan Ergin
 
GitFlow, SourceTree and GitLab
Shinu Suresh
 
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Atlassian
 
What's new and great in Rails 3 - Matt Gauger - Milwaukee Ruby Users Group De...
Matt Gauger
 
Git and Github workshop
Otto Kekäläinen
 
Git & Github for beginners
Paulo Henrique Nonaka
 
Introduction To Git Workshop
themystic_ca
 
Git in a nutshell
Pranesh Vittal
 
Matt Gauger - Lamp vs. the world - MKE PHP Users Group - December 14, 2010
Matt Gauger
 
Bitbucket
hariprasad1035
 
Git & Github Workshop - Le Wagon Melbourne
Paal Ringstad
 
Advanced Git Tutorial
Sage Sharp
 
Gittalk
prtinsley
 
The everyday developer's guide to version control with Git
E Carter
 
Ad

Viewers also liked (17)

PDF
How to successfully grow a code review culture
Nina Zakharenko
 
PDF
Djangocon 2014 angular + django
Nina Zakharenko
 
PDF
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
Nina Zakharenko
 
PDF
Memory Management In Python The Basics
Nina Zakharenko
 
DOCX
Calculo 3 1_ (1)
deiver1981
 
PPTX
Продается Yamaha mt-03
Eugene Skrebanov
 
PPTX
Huntsville police department interview questions
selinasimpson69
 
PPT
Chapter 2 - Atomic structure
AZI65
 
PPTX
The Power of LinkedIn in Your Business - Reasons To Use LinkedIn for Lead Gen...
Julie South
 
PDF
루이지엔 3기 포토북
Louisquartorze
 
PDF
Untitled Presentation
Elena Merchand
 
PPT
DM Lecture 3
asad199
 
PPTX
Presenting the fresh, modern style of Hodgson Design Associates
HDA-Vancouver
 
PPTX
Saguenay police department interview questions
selinasimpson69
 
PPT
Format Teks HTML
Sovira Aulia
 
PDF
A Graphic Analysis of Adults using Twitter
Aaron Outlen
 
PDF
Resultats par secteurs et villages municipales 2016 (pdf 7,2 mo)
Aboubakar Sanfo
 
How to successfully grow a code review culture
Nina Zakharenko
 
Djangocon 2014 angular + django
Nina Zakharenko
 
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
Nina Zakharenko
 
Memory Management In Python The Basics
Nina Zakharenko
 
Calculo 3 1_ (1)
deiver1981
 
Продается Yamaha mt-03
Eugene Skrebanov
 
Huntsville police department interview questions
selinasimpson69
 
Chapter 2 - Atomic structure
AZI65
 
The Power of LinkedIn in Your Business - Reasons To Use LinkedIn for Lead Gen...
Julie South
 
루이지엔 3기 포토북
Louisquartorze
 
Untitled Presentation
Elena Merchand
 
DM Lecture 3
asad199
 
Presenting the fresh, modern style of Hodgson Design Associates
HDA-Vancouver
 
Saguenay police department interview questions
selinasimpson69
 
Format Teks HTML
Sovira Aulia
 
A Graphic Analysis of Adults using Twitter
Aaron Outlen
 
Resultats par secteurs et villages municipales 2016 (pdf 7,2 mo)
Aboubakar Sanfo
 
Ad

Similar to Nina Zakharenko - Introduction to Git - Start SLC 2015 (20)

PDF
Version Control System - Git
Carlo Bernaschina
 
PPTX
GitHub Event.pptx
KeerthanaJ32
 
PPTX
Git Basics for Software Version Management
ishanmittal49
 
PPTX
Git and GitHub
Priya Nayak
 
PPTX
git & git hub course in information retrieval .pptx
AmirHosseinGhasemi9
 
PDF
Git Init (Introduction to Git)
GDSC UofT Mississauga
 
PPTX
Version controll.pptx
Md. Main Uddin Rony
 
PPTX
sample.pptx
UshaSuray
 
PPT
390a gitintro 12au
Nguyen Van Hung
 
KEY
Let's Git this Party Started: An Introduction to Git and GitHub
Kim Moir
 
ODP
Practical git for developers
Wim Godden
 
PDF
git & GitHub workshop
Shubhendra Singh Chauhan
 
ODP
Git presentation
Vikas Yaligar
 
PPTX
Introduction to Git and GitHub Part 1
Omar Fathy
 
PDF
Introduction to Git, DrupalCamp LA 2015
mwrather
 
PDF
git-commands-cheat-sheet-infopediya-com.pdf
murad khan
 
PPT
Git
Vijay Kani
 
PDF
Learn Git Fundamentals
Jatin Sharma
 
PDF
Getting Started with Git
Rick Umali
 
PPTX
Introduction to Git and GitHub
Bioinformatics and Computational Biosciences Branch
 
Version Control System - Git
Carlo Bernaschina
 
GitHub Event.pptx
KeerthanaJ32
 
Git Basics for Software Version Management
ishanmittal49
 
Git and GitHub
Priya Nayak
 
git & git hub course in information retrieval .pptx
AmirHosseinGhasemi9
 
Git Init (Introduction to Git)
GDSC UofT Mississauga
 
Version controll.pptx
Md. Main Uddin Rony
 
sample.pptx
UshaSuray
 
390a gitintro 12au
Nguyen Van Hung
 
Let's Git this Party Started: An Introduction to Git and GitHub
Kim Moir
 
Practical git for developers
Wim Godden
 
git & GitHub workshop
Shubhendra Singh Chauhan
 
Git presentation
Vikas Yaligar
 
Introduction to Git and GitHub Part 1
Omar Fathy
 
Introduction to Git, DrupalCamp LA 2015
mwrather
 
git-commands-cheat-sheet-infopediya-com.pdf
murad khan
 
Learn Git Fundamentals
Jatin Sharma
 
Getting Started with Git
Rick Umali
 

Recently uploaded (20)

PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Software Development Methodologies in 2025
KodekX
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 

Nina Zakharenko - Introduction to Git - Start SLC 2015

  • 1. Start slc Salt Lake City, UT January 31st, 2015
  • 3. PART 1 Overview WHY USE VERSION CONTROL COMMITTING TO YOUR REPOSITORY GIT IS NOT GITHUB REPOSITORY CREATE YOUR FIRST GIT PROJECT
  • 4. PART 2 OVERVIEW FINAL EXERCISEFORKING (IS NOT A DIRTY WORD) BRANCHES PULL REQUESTS SHARING YOUR WORK
  • 6. Have you ever found yourself creating multiple versions of a file to “save” your changes? ! Do you make multiple copies of files to make sure you have a working backup? VERSION PROBLEMS AND VERSIONS ARE ALL OF THEM. I GOT 99 PROBLEMS
  • 7. Version Control lets you maintain a history of your files. ! This history is easily browsed, attached to author names, and logged with extra commit information. ! This is especially useful when working in a team environment. VERSION CONTROL
  • 8. Git is a tool. ! More specifically, it’s an open source distributed version control system with an emphasis on data integrity and speed. GIT IS NOT GITHUB GIT github.com is a commercial website that allows you to host git repositories ! You can use it to find many open source projects, and even share your own. GIT HUB You might hear these terms used interchangeably. They’re not the same!
  • 10. LINGO REPOSITORY Local Repository - Where code is stored on your local machine ! Remote Repository - Where code is stored on a remote server (github, or internal server) ! Git stores information about the repository in a hidden .git directory contained in the same folder as the project. ! Will be commonly referred to as a repo. ! !
  • 11. LINGO CLONE Copying a github repository to your local machine.
  • 12. Let’s configure git on our local computer. ! Use the same email address that your github account is associated with. ! $ git config --global user.name "Your Name Here” ! $ git config --global user.email "[email protected]" ! SETTING UP GIT SET UP
  • 13. To set up a git repository locally, we navigate via the command line to the root of our project directory, and run the command: ! $ git init TWO WAYS TO CREATE A REPO LOCALLY Log in to your github account. ! Next, click on the ‘plus’ icon on the right side of the toolbar, then click new repository. ON GITHUB You skip a few setup steps by initializing on github.
  • 14. GITHUB - CREATE NEW REPO
  • 15. CLONING OUR NEW REPOSITORY GET THE URL CLONE THE PROJECT LOCALLY
  • 16. EXERCISE CREATE & CLONE A GITHUB REPO
  • 17. Creating a fork of my repository will copy it over to your github account. EXERCISE 1. GO TO GITHUB.COM Click the plus button on the right hand side, then select new repository. ! Be aware, public repos are visible on the internet. 2. CREATE A NEW REPOSITORY Copy the clone URL, then type in : ! $ git clone <copied_clone_url_here> 3. COPY THE REPO URL, GIT CLONE
  • 19. LINGO GIT ADD $ git add <filename> ! Git does not automatically keep track of all the files in a project directory. ! Use git add to make it aware of a new file, or use git add on an existing file to let git know you’ve made changes to it that you want to keep.
  • 20. LINGO THE STAGING AREA When you use $ git add on a file, it gets added to the staging area. ! The staging area contains snapshots of files that will be included in the next commit.
  • 22. LINGO GIT STATUS A git command that will give you a status update about your repository. ! This is the command I use the most in my day to day git usage. !
  • 24. LINGO GIT COMMIT Record a snapshot of the files in the staging area. ! $ git commit -m “A commit message contains helpful information” ! Note: When we run a $ git status after a commit, we’ll see a message that says “nothing to commit”
  • 25. LINGO GIT LOG A way to see what changes were made, and by who. ! $ git log !
  • 26. Use $ git diff <filename> to show the difference between the last checked in version of that file, and the modified file. LINGO DIFF
  • 27. SIDENOTE WHEN SHOULD I COMMIT MY CODE? Don’t wait for your code to be a in a perfect state before committing it. ! You’ll get the best benefits by committing early & often.
  • 28. EXERCISE COMMIT A FILE TO OUR REPO
  • 29. Using the command line, navigate to the repo directory. EXERCISE 1. NAVIGATE TO THE REPO Open the README.md file with your editor of choice. Make and save changes. 2. MODIFY THE README Run the command: $ git add README.md 3. ADD FILE TO STAGING AREA Run the command: $ git status to ensure your file is actually in the staging 4. RUN GIT STATUS Run the command: $ git commit -m “my commit message” 5. COMMIT YOUR CHANGES
  • 31. LINGO MASTER BRANCH The master branch is usually the “production ready” version of your codebase. ! That means that everything compiles, and all your tests pass. This is the version that customers will see - even if the customer is just you. ! There is only one master branch, and generally code is not committed directly to it.
  • 32. LINGO FEATURE BRANCHES Branches are extremely useful when you want to work on different features without interfering with a working copy of the code. ! When you’re done working on your feature branch, you can merge it back into master. ! If your repository is stored on a remote server, multiple developers can work on the same branch.
  • 34. When you create a new branch, you’re automatically switched to it. ! $ git checkout -b my_branch_name USING BRANCHES CREATE A NEW BRANCH $ git branch -a SEE ALL AVAILABLE BRANCHES $ git checkout my_other_branch CHECKOUT A DIFFERENT BRANCH
  • 35. MERGING BRANCHES MERGE FEATURE BRANCH INTO MASTER Once you’re satisfied with your feature branch, it’s time to merge it back into master. ! $ git checkout master ! $ git merge my_feature_branch !
  • 37. $ git checkout -b my_new_branch EXERCISE 1. CREATE A NEW BRANCH Review the previous exercise if you need hints. 2. COMMIT CHANGES 3. CHECKOUT MASTER $ git checkout master 4. MERGE YOUR BRANCH $ git merge my_new_branch
  • 38. 1 2 34 CREATE A BRANCH GIT COMMIT COMMIT TO STAGING GIT ADD ADD FILES TO STAGING AREA WRITE CODE HACK HACK HACK 5 GIT PUSH PUSH CHANGES UP TO REPOSITORY GIT CHECKOUT -B GIT WORKFLOW
  • 41. LINGO FORK Forking a repository on github will create a copy of that project in your github account.
  • 42. A copy that exists in your GitHub account and can be used to submit pull requests (changes) to the maintainers of the project. FORKING VS CLONING FORK A copy that does not exist in your GitHub account, and cannot change the remote repo unless the person who cloned it is added as a collaborator on the project. CLONE
  • 43. LINGO PUSH/PULL PUSH: Send a copy of the latest committed changes to the remote server. ! PULL: Retrieve a copy of the latest committed changes from the remote server. ! Note: If you’re working on a branch with other people, always run a pull command before getting started.
  • 44. LINGO PULL REQUEST A pull request is a proposal made by you to a project maintainer asking them to accept your changes to their code base. ! The maintainer can review a diff of the changes you made. 
 They can also leave general and code-line specific comments.
  • 46. Creating a fork of my repository will copy it over to your github account. FINAL EXERCISE - PT1 1. FORK MY REPOSITORY Go to the github page of your forked copy of gdi-pull-requests. ! Copy the repository URL, clone the project to your local machine. 2. CLONE YOUR FORKED REPOSITORY https://github.com/nnja/gdi-pull-requests git checkout -b <yourname>_branch 3. CREATE A FEATURE BRANCH
  • 47. Change over to the repository directory. ! Create a file called <yournamehere>.txt. FINAL EXERCISE - PT2 4. CREATE A FILE WITH A FUN FACT ABOUT YOU git add <yourname>.txt git commit -m “here’s a fun fact about me!” 5. ADD, THEN COMMIT YOUR FILE https://github.com/nnja/gdi-pull-requests git push -u origin <yourname>_branch 6. PUSH YOUR BRANCH TO THE REMOTE REPO
  • 48. FINAL EXERCISE - PT3 7. CREATE A PULL REQUEST https://github.com/nnja/gdi-pull-requests
  • 49. FIN
  • 50. RESOURCES ! The entire Pro Git e-book. ! The definitive manual. ! Dense, time consuming, but chock full of information. ! http://git-scm.com/ book/en/v2 ! Short, concise, and visual guides on beginner to advanced github topics. ! https:// guides.github.com/ A 15 minute interactive tutorial. Bonus: Works in your browser, no setup required. ! https://try.github.io/ levels/1/challenges/1 ADDITIONAL TRY GIT PRO GIT GITHUB GUIDES
  • 51. THANK YOU INTRO TO GIT @nnja girldevelopit.com