SlideShare a Scribd company logo
Intro	
  to	
  Working	
  with	
  
GIT	
  and	
  GitHub	
  
By	
  Yakov	
  Fain	
  and	
  Viktor	
  Gamov	
  
Farata	
  Systems	
  	
  
www.faratasystems.com	
  
Centralized	
  file	
  repositories	
  
Mary	
  (dev)	
  
local	
  files	
  

Vlad	
  (dev)	
  
local	
  files	
  
Ravikumar	
  (QA)	
  
local	
  files	
  

Remote	
  Server	
  
a.k.a.	
  repository	
  
a.k.a.	
  repo	
  	
  

www.faratasystems.com	
  

• 
• 
• 
• 
• 

SVN	
  
CVS	
  
TFS	
  
Perforce	
  
…	
  
Centralized	
  file	
  repositories	
  
Mary	
  (dev)	
  
local	
  files	
  

Vlad	
  (dev)	
  
local	
  files	
  
Ravikumar	
  (QA)	
  
local	
  files	
  

Remote	
  Server	
  
a.k.a.	
  repository	
  
a.k.a.	
  repo	
  	
  

• 
• 
• 
• 
• 

SVN	
  
CVS	
  
TFS	
  
Perforce	
  
…	
  

Mary	
  commits	
  her	
  code	
  changes	
  to	
  the	
  remote	
  server	
  and	
  checks	
  out	
  Vlad’s	
  changes	
  
	
  
Vlad	
  commits	
  his	
  code	
  changes	
  to	
  the	
  remote	
  server	
  and	
  checks	
  out	
  Mary’s	
  changes	
  
	
  
Ravikumar	
  only	
  checks	
  out	
  the	
  code	
  for	
  the	
  QA	
  tesOng.	
  	
  
	
  
www.faratasystems.com	
  
Distributed	
  file	
  repositories	
  

•  GIT	
  
•  Mercurial	
  
•  Bazaar	
  

Mary	
  (dev),	
  local	
  files,	
  local	
  repo	
  

Vlad	
  (dev),	
  local	
  files,	
  local	
  repo	
  
Remote	
  Repo	
  
Ravikumar	
  (QA),	
  local	
  repo	
  
Each	
  developer	
  has	
  a	
  full	
  local	
  copy	
  of	
  the	
  repo.	
  
	
  
It’s	
  hard	
  to	
  lose	
  the	
  repository	
  –	
  it’s	
  on	
  every	
  user’s	
  computer.	
  
	
  
Each	
  user	
  always	
  works	
  with	
  the	
  local	
  repo	
  unOl	
  he	
  needs	
  to	
  synchronize.	
  
www.faratasystems.com	
  
Working	
  with	
  GIT	
  
•  `	
  

Mary	
  (dev),	
  local	
  files,	
  local	
  repo	
  

Vlad	
  (dev),	
  local	
  files,	
  local	
  repo	
  

pull/push	
  
pull	
  

Remote	
  Git	
  Repo,	
  
like	
  GitHub	
  
	
  

Ravikumar	
  (QA),	
  local	
  repo	
  
Mary	
  works	
  on	
  the	
  plane	
  and	
  commits	
  her	
  code	
  changes	
  to	
  the	
  local	
  repo	
  
	
  
Vlad	
  commits	
  his	
  code	
  changes	
  to	
  the	
  local	
  repo	
  and	
  pushes	
  latest	
  changes	
  to	
  the	
  remote	
  
repo)	
  
	
  
Ravikumar	
  works	
  for	
  QA.	
  He	
  pulls	
  out	
  the	
  code	
  for	
  tesOng.	
  	
  
www.faratasystems.com	
  
Sync	
  up	
  with	
  the	
  remote	
  server	
  
pull	
  
push	
  

Remote	
  Git	
  	
  
repository	
  	
  

Mary	
  landed.	
  She	
  goes	
  to	
  Starbucks	
  to	
  get	
  online	
  to	
  pull	
  Vlad’s	
  changes	
  to	
  her	
  local	
  repo	
  
and	
  push	
  hers	
  changes	
  to	
  the	
  remote	
  one.	
  
	
  

www.faratasystems.com	
  
git	
  add	
  

Staging	
  Area	
  

git	
  reset	
  
www.faratasystems.com	
  
git	
  commit	
  

Paying	
  for	
  groceries	
  
Is	
  a	
  commitment.	
  But	
  sOll,	
  	
  
you	
  have	
  a	
  chance	
  to	
  return	
  them	
  	
  

git	
  reset	
  –hard	
  HEAD~1	
  
www.faratasystems.com	
  
git	
  push	
  

www.faratasystems.com	
  
git	
  pull	
  

Pulls	
  are	
  usually	
  done	
  from	
  a	
  	
  remote	
  repository,	
  which	
  could	
  be	
  a	
  central	
  
server	
  or	
  another	
  user’s	
  refrigerator	
  computer.	
  
	
  
www.faratasystems.com	
  
Downloads	
  and	
  documentaOon	
  
•  hYp://git-­‐scm.com	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  Git	
  	
  
•  hYps://help.github.com	
  	
  	
  	
  	
  	
  	
  GitHub	
  repo	
  
•  hYp://git-­‐scm.com/book	
  	
  	
  	
  	
  	
  Pro	
  Git	
  book	
  in	
  English	
  
•  hYp://git-­‐scm.com/book/ru	
  Pro	
  Git	
  book	
  in	
  Russian	
  
	
  
•  hYp://gitref.org	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  Reference	
  manual	
  
MAC	
  users,	
  if	
  you	
  already	
  had	
  an	
  older	
  version	
  of	
  git	
  installed,	
  aer	
  installing	
  the	
  new	
  version	
  	
  
add	
  this	
  to	
  ~/.bash_profile:	
  
	
  
export	
  PATH=/usr/local/git/bin:$PATH	
  
www.faratasystems.com	
  
Seang	
  up	
  name	
  and	
  email	
  
•  git	
  config	
  -­‐-­‐global	
  user.name	
  ”Yakov	
  Fain"	
  	
  
	
  
•  git	
  config	
  -­‐-­‐global	
  user.email	
  
"yakovfain@gmail.com"	
  

www.faratasystems.com	
  
Two	
  Ways	
  of	
  CreaOng	
  a	
  New	
  Git	
  Repo	
  
1.  From	
  scratch	
  
	
  

	
  	
  	
  	
  a)	
  cd	
  to	
  a	
  directory	
  where	
  your	
  project	
  files	
  are	
  
	
  	
  	
  	
  b)	
  run	
  git	
  init	
  (this	
  will	
  create	
  .git	
  subdirectory)	
  
	
  

2.  Clone	
  the	
  exisOng	
  repo	
  from	
  somewhere,	
  e.g.	
  
from	
  GitHub,	
  for	
  example:	
  
	
  
git	
  clone	
  git://github.com/yfain/javatraining.git	
  

	
  
You	
  can	
  start	
  version-­‐controlling	
  any	
  directory	
  at	
  any	
  Ome.	
  Just	
  go	
  into	
  this	
  dir	
  from	
  the	
  	
  
command	
  line	
  and	
  run	
  git	
  init	
  there.	
  	
  
www.faratasystems.com	
  
Walkthrough	
  1:	
  git	
  init	
  	
  
1.  Go	
  to	
  a	
  Terminal	
  window	
  
	
  
2.  Create	
  an	
  empty	
  dir	
  temp1:	
  
mkdir	
  temp1	
  
	
  
3.  cd	
  temp1	
  
	
  
4.  Directory	
  is	
  empty	
  
ls	
  –la	
  
	
  
5.  Create	
  a	
  local	
  git	
  repo	
  
git	
  init	
  
	
  
6.  Note	
  a	
  new	
  subdir	
  .git	
  
ls	
  –la	
  
	
  
7.  See	
  the	
  structure	
  of	
  the	
  new	
  repo	
  
	
  tree	
  –a	
  	
  
	
  
There	
  is	
  no	
  logs	
  directory	
  yet.	
  
If	
  tree	
  command	
  doesn’t	
  work,	
  watch	
  this:	
  
The	
  objects	
  directrory	
  is	
  empty.	
  	
  	
  	
  
hYp://bit.ly/1bX2HqH	
  	
  	
  
This	
  is	
  your	
  enOre	
  new	
  Git	
  repo.	
  	
  	
  	
  	
   www.faratasystems.com	
  
You	
  can	
  start	
  version-­‐controlling	
  any	
  directory	
  at	
  
any	
  Ome.	
  	
  
	
  
Just	
  go	
  into	
  this	
  directory	
  from	
  the	
  command	
  line	
  
and	
  run	
  git	
  init	
  there.	
  	
  

www.faratasystems.com	
  
CreaOng	
  a	
  file	
  and	
  commiang	
  to	
  a	
  repo	
  
1.	
  Create	
  index.html:	
  


<html>"
<body bgcolor="red”>"
</body>"
</html>"
	
  
2.	
  Open	
  it	
  in	
  your	
  browser	
  –	
  it’s	
  red	
  
	
  
	
  
	
  
	
  
3.	
  git	
  status	
  
4.	
  git	
  add	
  .	
  
5.	
  git	
  commit	
  –m	
  “created	
  red	
  page”	
  
	
  
6.	
  Go	
  to	
  your	
  .git	
  directory.	
  	
  
	
  	
  	
  	
  	
  a)	
  You’ll	
  see	
  new	
  log	
  subdir	
  
	
  	
  	
  	
  	
  b)	
  Look	
  inside	
  your	
  objects	
  dir	
  

www.faratasystems.com	
  
Branching	
  	
  
•  The	
  default	
  branch	
  is	
  master	
  
git	
  branch	
  	
  
•  To	
  create	
  a	
  branch	
  named	
  blue	
  
git	
  branch	
  blue	
  
•  To	
  create	
  and	
  switch	
  to	
  branch	
  blue:	
  
	
  git	
  checkout	
  –b	
  blue	
  
	
  

•  To	
  switch	
  back	
  to	
  master:	
  
git	
  checkout	
  	
  master	
  
	
  
•  To	
  merge	
  blue	
  into	
  master:	
  
	
  	
  	
  	
  git	
  merge	
  blue	
  

www.faratasystems.com	
  
Walkthrough	
  2:	
  Adding	
  Another	
  Branch	
  
1.  Check	
  which	
  branch	
  are	
  you	
  in	
  (should	
  be	
  in	
  master)	
  
	
  	
  	
  	
  	
  	
  	
  git	
  branch	
  
	
  
2.	
  Create	
  a	
  new	
  branch	
  named	
  blue	
  and	
  switch	
  to	
  it:	
  
	
  	
  	
  	
  	
  	
  	
  git	
  checkout	
  –b	
  blue	
  
	
  
3.	
  Change	
  the	
  background	
  in	
  index.html	
  to	
  be	
  blue:	
  
<body bgcolor=”blue">"
	
  Open	
  index.html	
  in	
  the	
  browser	
  –	
  background	
  should	
  be	
  blue 

"
4.	
  Commit	
  the	
  change	
  
	
  	
  	
  	
  git	
  add	
  .	
  
	
  	
  	
  	
  git	
  commit	
  –m	
  “changing	
  background	
  from	
  red	
  to	
  blue”	
  
	
  
5.	
  Switch	
  back	
  to	
  the	
  branch	
  master	
  
	
  	
  	
  	
  git	
  checkout	
  master	
  
	
  
6.	
  Open	
  index.html	
  in	
  your	
  browser	
  –	
  background	
  should	
  be	
  red.	
  	
  
Check	
  your	
  working	
  directory	
  –	
  there	
  is	
  only	
  one	
  version	
  of	
  index.html.	
  
www.faratasystems.com	
  
Walkthrough	
  3:	
  One	
  more	
  branch	
  +	
  merging	
  
1.  Create	
  and	
  switch	
  one	
  more	
  branch	
  called	
  branch2	
  
git	
  checkout	
  –b	
  branch2	
  
	
  
2.  Add	
  some	
  text	
  inside	
  the	
  <body>	
  tag	
  in	
  index.html:	
  
<h1>Hello	
  from	
  branch2</h1>	
  
	
  
Open	
  index.html	
  in	
  the	
  Web	
  browser	
  
	
  
3.  Commit	
  the	
  change:	
  
git	
  add	
  .	
  
git	
  commit	
  –m	
  “added	
  some	
  text	
  to	
  the	
  page”	
  
	
  
4.  Switch	
  back	
  to	
  master	
  branch	
  
git	
  checkout	
  master	
  
	
  
Open	
  index.html	
  –	
  it’s	
  red	
  and	
  no	
  text	
  
	
  
5.  Merge	
  with	
  branch2	
  
git	
  merge	
  branch2	
  
Open	
  index.html	
  –	
  it’s	
  red	
  with	
  text	
  
www.faratasystems.com	
  
Walkthrough	
  3:	
  Merge	
  conflict	
  
Merging	
  master	
  with	
  blue	
  will	
  cause	
  
the	
  conflict.	
  	
  
Master	
  branch	
  has	
  
	
  <body	
  bgcolor="red">	
  
Blue	
  branch	
  has	
  	
  
<body	
  bgcolor=”blue”>	
  
	
  
	
  
Open	
  index.html	
  in	
  the	
  editor	
  and	
  
manually	
  change	
  it	
  to	
  keep	
  the	
  line	
  
with	
  blue	
  color.	
  	
  
	
  
The	
  final	
  version	
  of	
  index.html:	
  
	
  
<html>	
  
	
  	
  <body	
  bgcolor="blue">	
  
	
  	
  	
  	
  	
  	
  <h1>Hello	
  from	
  branch2</h1>	
  
	
  	
  </body>	
  
</html>	
  	
  
	
  
Do	
  git	
  add	
  .	
  and	
  git	
  commit	
  	
  	
  

www.faratasystems.com	
  
Git	
  config	
  files	
  
Global	
  Git	
  Config:	
  	
  	
  
~/.gitconfig	
  
	
  
Local	
  Git	
  Config:	
  
	
  your_project_dir/.git/config	
  

www.faratasystems.com	
  
GitHub:	
  	
  HosOng	
  for	
  Git	
  

Note:	
  Bitbucket.org	
  is	
  another	
  hosOng	
  service	
  for	
  Git	
  repositories.	
  
	
  
Pricing:	
  hYps://bitbucket.org/account/user/yfain/plans/	
  	
  
www.faratasystems.com	
  
GitHub	
  –	
  Online	
  Project	
  HosOng	
  For	
  Git	
  
To	
  start	
  using	
  GitHub	
  create	
  an	
  account	
  there.	
  	
  
	
  
You	
  can	
  create	
  an	
  organizaOon	
  and	
  add	
  users	
  to	
  
the	
  organizaOon.	
  
	
  

www.faratasystems.com	
  
Create	
  New	
  Repository	
  on	
  GitHub	
  	
  

1.  Login	
  to	
  your	
  Github	
  account	
  
2.  Select	
  the	
  tab	
  Repositories	
  and	
  create	
  new	
  
Repository	
  	
  
3.  Enter	
  the	
  name	
  of	
  the	
  project	
  and	
  its	
  
descripOon.	
  
www.faratasystems.com	
  
Publishing	
  Your	
  Local	
  Project	
  to	
  GitHub	
  
Aer	
  the	
  repository	
  is	
  created	
  you’ll	
  see	
  commands	
  to	
  run	
  from	
  
your	
  desktop.	
  Say,	
  you	
  named	
  the	
  repo	
  temp1:	
  

Open	
  command	
  or	
  Terminal	
  window,	
  switch	
  to	
  temp1	
  and	
  enter	
  
the	
  above	
  commands.	
  
For	
  more	
  details	
  read	
  this:	
  
hYps://help.github.com/arOcles/create-­‐a-­‐repo	
  	
  
www.faratasystems.com	
  
Downloading	
  ExisOng	
  Repo	
  from	
  GitHub	
  
Either	
  click	
  on	
  the	
  buYon	
  Clone	
  in	
  Desktop	
  
	
  
	
  or	
  	
  
	
  
download	
  the	
  repo	
  as	
  zip.	
  
	
  

To	
  clone	
  from	
  a	
  command	
  line	
  you	
  need	
  to	
  know	
  the	
  URL	
  of	
  the	
  repo,	
  for	
  example:	
  	
  
	
  
git	
  clone	
  git://github.com/johnsmith/mygreatprograms.git	
  
	
  
or	
  
	
  
git	
  clone	
  hYps://github.com/johnsmith/mygreatprograms	
  
www.faratasystems.com	
  
What’s	
  Pull	
  Request	
  
•  The	
  user	
  Viktor,	
  who	
  doesn’t	
  belong	
  to	
  our	
  project	
  can	
  
fork	
  the	
  proj,	
  make	
  the	
  changes	
  and	
  send	
  a	
  Pull	
  
Request.	
  
	
  
•  If	
  Yakov	
  agrees	
  to	
  the	
  pull	
  request	
  he	
  pulls	
  the	
  change	
  
from	
  Viktor’s	
  repo	
  to	
  ours	
  –	
  he	
  goes	
  to	
  Pull	
  Requests	
  
and	
  selects	
  Merge	
  Pull	
  Request.	
  

www.faratasystems.com	
  
GitHub	
  Fork	
  
Fork	
  
Yakov’s	
  
Github	
  Repo	
  

Pull	
  Request	
  

pull,	
  push	
  

pull,	
  push	
  

Yakov’s	
  
Desktop	
  

Viktor’s	
  
Github	
  Repo	
  

pull,	
  push	
  

www.faratasystems.com	
  

Viktor’s	
  
Desktop	
  
Merging	
  Pull	
  Request	
  Sample	
  1	
  

www.faratasystems.com	
  
Merging	
  Pull	
  Request	
  Sample	
  2	
  

www.faratasystems.com	
  
Contact	
  Info	
  
•  yfain@faratasystems.com	
  
•  viktor.gamov@faratasystems.com	
  	
  
•  @yfain	
  	
  
•  @gAmUssA	
  

www.faratasystems.com	
  

More Related Content

PPTX
Git and GitHub
PPTX
Introduction to Git / Github
PDF
Git and github - Verson Control for the Modern Developer
PPTX
Intro to git and git hub
KEY
Matt Gauger - Git & Github web414 December 2010
PDF
Git in a nutshell
PPTX
GIT in a nutshell
DOCX
Bitbucket
Git and GitHub
Introduction to Git / Github
Git and github - Verson Control for the Modern Developer
Intro to git and git hub
Matt Gauger - Git & Github web414 December 2010
Git in a nutshell
GIT in a nutshell
Bitbucket

What's hot (20)

PPTX
PDF
Git, from the beginning
PPTX
Git hub ppt presentation
PDF
Git & GitHub WorkShop
PDF
Inside GitHub with Chris Wanstrath
KEY
Git: from Novice to Expert
PDF
Git and github 101
PDF
Github - Git Training Slides: Foundations
PDF
Git & Github for beginners
PPTX
Git Terminologies
PDF
Git and Github
PDF
Github - Le Wagon Melbourne
PPTX
Intro to Git and GitHub
PPTX
Git-ing out of your git messes
PDF
Git-ing out of your git messes - Fluent Conf 2017
KEY
The everyday developer's guide to version control with Git
PDF
Switching to Git
KEY
Let's Git this Party Started: An Introduction to Git and GitHub
PDF
git and github
PDF
Git and GitHub at the San Francisco JUG
Git, from the beginning
Git hub ppt presentation
Git & GitHub WorkShop
Inside GitHub with Chris Wanstrath
Git: from Novice to Expert
Git and github 101
Github - Git Training Slides: Foundations
Git & Github for beginners
Git Terminologies
Git and Github
Github - Le Wagon Melbourne
Intro to Git and GitHub
Git-ing out of your git messes
Git-ing out of your git messes - Fluent Conf 2017
The everyday developer's guide to version control with Git
Switching to Git
Let's Git this Party Started: An Introduction to Git and GitHub
git and github
Git and GitHub at the San Francisco JUG
Ad

Viewers also liked (10)

PPS
La Evolucion Del Hombre
PDF
Running a Virtual Company
PDF
不自然なcar/ナチュラルにconsして
PDF
Vortrag Veen 19 09 2005
PDF
Net Generation Learning
PDF
Intro to Git and GitHub
PPTX
Force.com Migration Tool
PDF
Intro to Git and GitHub
PDF
Scripted Data Loads with Salesforce DataLoader and ANT
PDF
Seven Versions of One Web Application
La Evolucion Del Hombre
Running a Virtual Company
不自然なcar/ナチュラルにconsして
Vortrag Veen 19 09 2005
Net Generation Learning
Intro to Git and GitHub
Force.com Migration Tool
Intro to Git and GitHub
Scripted Data Loads with Salesforce DataLoader and ANT
Seven Versions of One Web Application
Ad

Similar to Princeton jug git_github (20)

PDF
簡單介紹git
PPTX
Git Basics for Software Version Management
PDF
Subversion to Git Migration
PPTX
Git walkthrough
PPTX
Git reposirory descritiopn use this for demo p
PDF
Git and Github slides.pdf
PDF
Git and Github workshop ppt slide by slide
PPTX
tech winter break workshop on git &git hub.pptx
PPTX
Introduction to Git and Github
PPT
Git basic
PPT
Git workflow libre semikov
PPT
390a gitintro 12au
KEY
Git Tech Talk
PPTX
Git and Github workshop GDSC MLRITM
PPTX
sample.pptx
KEY
Git Distributed Version Control System
PDF
Introduction to Git for Artists
PDF
The Basics of Open Source Collaboration With Git and GitHub
PDF
Git training v10
PDF
簡單介紹git
Git Basics for Software Version Management
Subversion to Git Migration
Git walkthrough
Git reposirory descritiopn use this for demo p
Git and Github slides.pdf
Git and Github workshop ppt slide by slide
tech winter break workshop on git &git hub.pptx
Introduction to Git and Github
Git basic
Git workflow libre semikov
390a gitintro 12au
Git Tech Talk
Git and Github workshop GDSC MLRITM
sample.pptx
Git Distributed Version Control System
Introduction to Git for Artists
The Basics of Open Source Collaboration With Git and GitHub
Git training v10

More from Yakov Fain (20)

PDF
Type script for_java_dev_jul_2020
PDF
Web sockets in Angular
PDF
Using JHipster for generating Angular/Spring Boot apps
PDF
Using JHipster for generating Angular/Spring Boot apps
PDF
TypeScript for Java Developers
PDF
Reactive Streams and RxJava2
PDF
Using JHipster 4 for generating Angular/Spring Boot apps
PDF
Angular 4 for Java Developers
PDF
Reactive programming in Angular 2
PDF
Reactive Thinking in Java with RxJava2
PDF
Angular2 Development for Java developers
PDF
Reactive Thinking in Java
PDF
Angular 2 for Java Developers
PDF
Overview of the AngularJS framework
PDF
Dart for Java Developers
PDF
RESTful services and OAUTH protocol in IoT
PDF
Integrating consumers IoT devices into Business Workflow
PDF
Intro to JavaScript
PDF
Java Intro: Unit1. Hello World
PDF
Speed up your Web applications with HTML5 WebSockets
Type script for_java_dev_jul_2020
Web sockets in Angular
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot apps
TypeScript for Java Developers
Reactive Streams and RxJava2
Using JHipster 4 for generating Angular/Spring Boot apps
Angular 4 for Java Developers
Reactive programming in Angular 2
Reactive Thinking in Java with RxJava2
Angular2 Development for Java developers
Reactive Thinking in Java
Angular 2 for Java Developers
Overview of the AngularJS framework
Dart for Java Developers
RESTful services and OAUTH protocol in IoT
Integrating consumers IoT devices into Business Workflow
Intro to JavaScript
Java Intro: Unit1. Hello World
Speed up your Web applications with HTML5 WebSockets

Recently uploaded (20)

PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Cloud computing and distributed systems.
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPT
Teaching material agriculture food technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Big Data Technologies - Introduction.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
The AUB Centre for AI in Media Proposal.docx
Unlocking AI with Model Context Protocol (MCP)
Reach Out and Touch Someone: Haptics and Empathic Computing
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Understanding_Digital_Forensics_Presentation.pptx
Cloud computing and distributed systems.
Mobile App Security Testing_ A Comprehensive Guide.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Teaching material agriculture food technology
Review of recent advances in non-invasive hemoglobin estimation
Encapsulation_ Review paper, used for researhc scholars
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Spectral efficient network and resource selection model in 5G networks
Big Data Technologies - Introduction.pptx
Encapsulation theory and applications.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows

Princeton jug git_github

  • 1. Intro  to  Working  with   GIT  and  GitHub   By  Yakov  Fain  and  Viktor  Gamov   Farata  Systems     www.faratasystems.com  
  • 2. Centralized  file  repositories   Mary  (dev)   local  files   Vlad  (dev)   local  files   Ravikumar  (QA)   local  files   Remote  Server   a.k.a.  repository   a.k.a.  repo     www.faratasystems.com   •  •  •  •  •  SVN   CVS   TFS   Perforce   …  
  • 3. Centralized  file  repositories   Mary  (dev)   local  files   Vlad  (dev)   local  files   Ravikumar  (QA)   local  files   Remote  Server   a.k.a.  repository   a.k.a.  repo     •  •  •  •  •  SVN   CVS   TFS   Perforce   …   Mary  commits  her  code  changes  to  the  remote  server  and  checks  out  Vlad’s  changes     Vlad  commits  his  code  changes  to  the  remote  server  and  checks  out  Mary’s  changes     Ravikumar  only  checks  out  the  code  for  the  QA  tesOng.       www.faratasystems.com  
  • 4. Distributed  file  repositories   •  GIT   •  Mercurial   •  Bazaar   Mary  (dev),  local  files,  local  repo   Vlad  (dev),  local  files,  local  repo   Remote  Repo   Ravikumar  (QA),  local  repo   Each  developer  has  a  full  local  copy  of  the  repo.     It’s  hard  to  lose  the  repository  –  it’s  on  every  user’s  computer.     Each  user  always  works  with  the  local  repo  unOl  he  needs  to  synchronize.   www.faratasystems.com  
  • 5. Working  with  GIT   •  `   Mary  (dev),  local  files,  local  repo   Vlad  (dev),  local  files,  local  repo   pull/push   pull   Remote  Git  Repo,   like  GitHub     Ravikumar  (QA),  local  repo   Mary  works  on  the  plane  and  commits  her  code  changes  to  the  local  repo     Vlad  commits  his  code  changes  to  the  local  repo  and  pushes  latest  changes  to  the  remote   repo)     Ravikumar  works  for  QA.  He  pulls  out  the  code  for  tesOng.     www.faratasystems.com  
  • 6. Sync  up  with  the  remote  server   pull   push   Remote  Git     repository     Mary  landed.  She  goes  to  Starbucks  to  get  online  to  pull  Vlad’s  changes  to  her  local  repo   and  push  hers  changes  to  the  remote  one.     www.faratasystems.com  
  • 7. git  add   Staging  Area   git  reset   www.faratasystems.com  
  • 8. git  commit   Paying  for  groceries   Is  a  commitment.  But  sOll,     you  have  a  chance  to  return  them     git  reset  –hard  HEAD~1   www.faratasystems.com  
  • 10. git  pull   Pulls  are  usually  done  from  a    remote  repository,  which  could  be  a  central   server  or  another  user’s  refrigerator  computer.     www.faratasystems.com  
  • 11. Downloads  and  documentaOon   •  hYp://git-­‐scm.com                                Git     •  hYps://help.github.com              GitHub  repo   •  hYp://git-­‐scm.com/book            Pro  Git  book  in  English   •  hYp://git-­‐scm.com/book/ru  Pro  Git  book  in  Russian     •  hYp://gitref.org                                              Reference  manual   MAC  users,  if  you  already  had  an  older  version  of  git  installed,  aer  installing  the  new  version     add  this  to  ~/.bash_profile:     export  PATH=/usr/local/git/bin:$PATH   www.faratasystems.com  
  • 12. Seang  up  name  and  email   •  git  config  -­‐-­‐global  user.name  ”Yakov  Fain"       •  git  config  -­‐-­‐global  user.email   "yakovfain@gmail.com"   www.faratasystems.com  
  • 13. Two  Ways  of  CreaOng  a  New  Git  Repo   1.  From  scratch            a)  cd  to  a  directory  where  your  project  files  are          b)  run  git  init  (this  will  create  .git  subdirectory)     2.  Clone  the  exisOng  repo  from  somewhere,  e.g.   from  GitHub,  for  example:     git  clone  git://github.com/yfain/javatraining.git     You  can  start  version-­‐controlling  any  directory  at  any  Ome.  Just  go  into  this  dir  from  the     command  line  and  run  git  init  there.     www.faratasystems.com  
  • 14. Walkthrough  1:  git  init     1.  Go  to  a  Terminal  window     2.  Create  an  empty  dir  temp1:   mkdir  temp1     3.  cd  temp1     4.  Directory  is  empty   ls  –la     5.  Create  a  local  git  repo   git  init     6.  Note  a  new  subdir  .git   ls  –la     7.  See  the  structure  of  the  new  repo    tree  –a       There  is  no  logs  directory  yet.   If  tree  command  doesn’t  work,  watch  this:   The  objects  directrory  is  empty.         hYp://bit.ly/1bX2HqH       This  is  your  enOre  new  Git  repo.           www.faratasystems.com  
  • 15. You  can  start  version-­‐controlling  any  directory  at   any  Ome.       Just  go  into  this  directory  from  the  command  line   and  run  git  init  there.     www.faratasystems.com  
  • 16. CreaOng  a  file  and  commiang  to  a  repo   1.  Create  index.html:   
 <html>" <body bgcolor="red”>" </body>" </html>"   2.  Open  it  in  your  browser  –  it’s  red           3.  git  status   4.  git  add  .   5.  git  commit  –m  “created  red  page”     6.  Go  to  your  .git  directory.              a)  You’ll  see  new  log  subdir            b)  Look  inside  your  objects  dir   www.faratasystems.com  
  • 17. Branching     •  The  default  branch  is  master   git  branch     •  To  create  a  branch  named  blue   git  branch  blue   •  To  create  and  switch  to  branch  blue:    git  checkout  –b  blue     •  To  switch  back  to  master:   git  checkout    master     •  To  merge  blue  into  master:          git  merge  blue   www.faratasystems.com  
  • 18. Walkthrough  2:  Adding  Another  Branch   1.  Check  which  branch  are  you  in  (should  be  in  master)                git  branch     2.  Create  a  new  branch  named  blue  and  switch  to  it:                git  checkout  –b  blue     3.  Change  the  background  in  index.html  to  be  blue:   <body bgcolor=”blue">"  Open  index.html  in  the  browser  –  background  should  be  blue 
 " 4.  Commit  the  change          git  add  .          git  commit  –m  “changing  background  from  red  to  blue”     5.  Switch  back  to  the  branch  master          git  checkout  master     6.  Open  index.html  in  your  browser  –  background  should  be  red.     Check  your  working  directory  –  there  is  only  one  version  of  index.html.   www.faratasystems.com  
  • 19. Walkthrough  3:  One  more  branch  +  merging   1.  Create  and  switch  one  more  branch  called  branch2   git  checkout  –b  branch2     2.  Add  some  text  inside  the  <body>  tag  in  index.html:   <h1>Hello  from  branch2</h1>     Open  index.html  in  the  Web  browser     3.  Commit  the  change:   git  add  .   git  commit  –m  “added  some  text  to  the  page”     4.  Switch  back  to  master  branch   git  checkout  master     Open  index.html  –  it’s  red  and  no  text     5.  Merge  with  branch2   git  merge  branch2   Open  index.html  –  it’s  red  with  text   www.faratasystems.com  
  • 20. Walkthrough  3:  Merge  conflict   Merging  master  with  blue  will  cause   the  conflict.     Master  branch  has    <body  bgcolor="red">   Blue  branch  has     <body  bgcolor=”blue”>       Open  index.html  in  the  editor  and   manually  change  it  to  keep  the  line   with  blue  color.       The  final  version  of  index.html:     <html>      <body  bgcolor="blue">              <h1>Hello  from  branch2</h1>      </body>   </html>       Do  git  add  .  and  git  commit       www.faratasystems.com  
  • 21. Git  config  files   Global  Git  Config:       ~/.gitconfig     Local  Git  Config:    your_project_dir/.git/config   www.faratasystems.com  
  • 22. GitHub:    HosOng  for  Git   Note:  Bitbucket.org  is  another  hosOng  service  for  Git  repositories.     Pricing:  hYps://bitbucket.org/account/user/yfain/plans/     www.faratasystems.com  
  • 23. GitHub  –  Online  Project  HosOng  For  Git   To  start  using  GitHub  create  an  account  there.       You  can  create  an  organizaOon  and  add  users  to   the  organizaOon.     www.faratasystems.com  
  • 24. Create  New  Repository  on  GitHub     1.  Login  to  your  Github  account   2.  Select  the  tab  Repositories  and  create  new   Repository     3.  Enter  the  name  of  the  project  and  its   descripOon.   www.faratasystems.com  
  • 25. Publishing  Your  Local  Project  to  GitHub   Aer  the  repository  is  created  you’ll  see  commands  to  run  from   your  desktop.  Say,  you  named  the  repo  temp1:   Open  command  or  Terminal  window,  switch  to  temp1  and  enter   the  above  commands.   For  more  details  read  this:   hYps://help.github.com/arOcles/create-­‐a-­‐repo     www.faratasystems.com  
  • 26. Downloading  ExisOng  Repo  from  GitHub   Either  click  on  the  buYon  Clone  in  Desktop      or       download  the  repo  as  zip.     To  clone  from  a  command  line  you  need  to  know  the  URL  of  the  repo,  for  example:       git  clone  git://github.com/johnsmith/mygreatprograms.git     or     git  clone  hYps://github.com/johnsmith/mygreatprograms   www.faratasystems.com  
  • 27. What’s  Pull  Request   •  The  user  Viktor,  who  doesn’t  belong  to  our  project  can   fork  the  proj,  make  the  changes  and  send  a  Pull   Request.     •  If  Yakov  agrees  to  the  pull  request  he  pulls  the  change   from  Viktor’s  repo  to  ours  –  he  goes  to  Pull  Requests   and  selects  Merge  Pull  Request.   www.faratasystems.com  
  • 28. GitHub  Fork   Fork   Yakov’s   Github  Repo   Pull  Request   pull,  push   pull,  push   Yakov’s   Desktop   Viktor’s   Github  Repo   pull,  push   www.faratasystems.com   Viktor’s   Desktop  
  • 29. Merging  Pull  Request  Sample  1   www.faratasystems.com  
  • 30. Merging  Pull  Request  Sample  2   www.faratasystems.com  
  • 31. Contact  Info   •  yfain@faratasystems.com   •  viktor.gamov@faratasystems.com     •  @yfain     •  @gAmUssA   www.faratasystems.com