SlideShare une entreprise Scribd logo
1  sur  35
GITHUB
& A BIT ON WORKFLOW
Thursday, 30 May 13
WHAT IS SCM?
SOURCE CODE MANAGEMENT
• Storing versions of files
• Good backup
• Important when working in teams
• Points to revert back to
Thursday, 30 May 13
SCM SYSTEMS
SOME EXAMPLES
• Mercurial
SUPER QUICK, LARGE DEV-TEAMS, SIMPLE
• Subversion
WIDEST ADOPTION, CHECKING OUT FILES, CENTRAL SERVER
• Git
GROWING QUICKLY, SUPER FAST, DELTA CHANGES, GITHUB, AWESOME
Thursday, 30 May 13
GIT VS GITHUB
• Distributed source code management
system
• Hosted solution to facilitate easy
collaboration on Git repositories
Thursday, 30 May 13
WHY GIT?
• Distributed
• Super-fast
• Lightweight
• Server-less
• Personal preference
• GitHub
Thursday, 30 May 13
WHY GIT?
• Distributed
• Super-fast
• Lightweight
• Personal preference
• GitHub
Thursday, 30 May 13
WHY GIT?
• Distributed
• Super-fast
• Lightweight
• Personal preference
• GitHub
Thursday, 30 May 13
WHY GIT?
• Distributed
• Super-fast
• Lightweight
• Personal preference
• GitHub
Thursday, 30 May 13
WHY GIT?
• Distributed
• Super-fast
• Lightweight
• Personal preference
• GitHub
Thursday, 30 May 13
WHY GIT?
• Distributed
• Super-fast
• Lightweight
• Personal preference
• GitHub
Thursday, 30 May 13
GITHUB, GITHUB, GITHUB
MORE ON THIS MAGICAL TOOL
• Git repository hosting
• Web tool suite
• Collaborative development
• Social coding (forking)
Thursday, 30 May 13
INSTALLING GIT
HANDS-ON #1
MAC
<3 - Easy as pie
WINDOWS
Good luck
https://help.github.com/articles/set-up-git
Thanks GitHub, let’s visit:
Thursday, 30 May 13
GIT WORKFLOW
$ cd ~/Desktop/
$ mkdir git
cd is the unix command for
‘change directory’. ~/ is
your home directory.
mkdir is the unix command
for ‘make directory’. The
same thing as creating a
new folder.
Thursday, 30 May 13
GIT WORKFLOW
git init will turn the current
folder into a git repository.
Git will now monitor this
folder and any files and
sub-directories for changes
$ cd ~/Desktop/
$ mkdir git
$ cd git
$ git init
Thursday, 30 May 13
GIT WORKFLOW
git status tells you the
current status of the
repository (changed files
etc)
Now: open up your text
editor and create a blank
txt file. Save it in the same
directory as your git repo.
$ git init
$ git status
Thursday, 30 May 13
GIT WORKFLOW
git status will now tell you
there are untracked files
git add [filename] is used to
add files to the stage for a
commit
$ git status
$ git add hello.txt
Thursday, 30 May 13
WOAH, SLOW DOWN!
SOME GIT TERMINOLOGY
STAGE
A SET OF “STAGED” CHANGES THAT WILL BE PART OF A
COMMIT
COMMIT
A PERMANENT SNAPSHOT OFYOUR GIT REPOSITORY AT A
GIVEN TIME
Thursday, 30 May 13
GIT WORKFLOW
git commit will create a
snapshot of your repository
saving all staged changes
We use the -m flag
followed by a string to
define a commit message.
Keep in mind that unstaged
changes won’t be saved.
$ git status
$ git add hello.txt
$ git commit -m “Initial commit”
Thursday, 30 May 13
GIT WORKFLOW
git status will show no
changes
1. Make a change to
hello.txt
2. Make a new file
3. Commit JUST the new
file
$ git status
$ git add hello.txt
$ git commit -m “Initial commit”
$ git status
Thursday, 30 May 13
HOLD UP!
What do you notice?
Thursday, 30 May 13
TEAM WORKFLOW
USING GIT & GITHUB
• Role-oriented AND random editing of files
without fear of overwriting anyone else’s work
• Branching off from the master (main) code base to
work on individual features WITHOUT breaking
the whole site
• Multiple backups of the code-base
• Ability to revert to ANY previous version of a file
Thursday, 30 May 13
‘ADVANCED’ TERMINOLOGY
PUSHING
PUSHYOUR COMMITS TO THE UPSTREAM SERVER (GITHUB)
PULLING
PULL DOWN THE LATEST COMMITS FROM THE UPSTREAM SERVER (GITHUB)
MASTER BRANCH
MASTER IS THE DEFAULT BRANCH INYOUR REPOSITORY.THIS IS THE MAIN CODE BASE
AND SHOULD AT ALL TIMES CONTAIN DEPLOYABLE CODE.
BRANCHING
CREATING ADDITIONAL BRANCHES OFF OF MASTER TO WORK ON INDIVIDUAL FEATURES
Thursday, 30 May 13
PUSHING & PULLING
USING AN UPSTREAM SERVER (GITHUB)
• In your teams: push and pull as often as
possible
• Before starting work on, always PULL
• Try to use another communication tool (FB,
Skype etc) to keep in touch when developing
and tell eachother when you have made
changes.
Thursday, 30 May 13
OH SHIT!
SOMEONE EFFED’ UP
•You probably went to push some commits
without pulling from GitHub and now you have
some screwed up, out of order repo.
•Solving this problem can be a bitch so cross
your fingers and hope for the best.
Thursday, 30 May 13
OH SHIT!
THE SOLUTION
• Run git pull. Git will force you to merge
the changes but you will need to do this
manually.
• Run git merge. Git will merge your
commits with the upstream commits into
a new commit, then push.
Thursday, 30 May 13
BRANCHING
SOME GIT AWESOMENESS
• Branching should be used when you want to
work on a specific feature
• Give your branches descriptive names
i.e. user-login or pretty-forms
• Don’t try and make your branches all
encompassing (keep them small and modular)
Thursday, 30 May 13
USING GITHUB
HANDS-ON #2
http://github.com
Go to ^ and make an account
Thursday, 30 May 13
TEAM WORKFLOW
BRANCHING, PULL REQUESTS & MERGING
• Get in your teams
• The technical lead should create a repository on
their account then go to settings and invite the
other members of your team as collaborators.
• Everybody grab the URL found on the repo page:
Thursday, 30 May 13
BRANCHING
$ cd ~/Desktop/
$ git clone https://github.com/
codycarnachan/mds.git
Let’s reset our directory to
our Desktop.
git clone is the command
for cloning a repository.
Make sure you put your
own URL in; you won’t be
able to clone repositories
that you aren’t a
collaborator on.
Thursday, 30 May 13
BRANCHING
$ cd ~/Desktop/
$ git clone https://github.com/
codycarnachan/mds.git
$ git checkout -b new-branch-
name
git checkout -b
[branchname] is the
command for creating a
new branch and switching
to it (or just switching if it
already exists)
Changes you make now will
be independent to the
master brach
Thursday, 30 May 13
BRANCHING
$ cd ~/Desktop/
$ git clone https://github.com/
codycarnachan/mds.git
$ git checkout -b new-branch-
name
Create a file with some
text and then commit it.
Note: There is a different
format to push your new
local branch to the
upstream server:
git push -u origin
[branchname]
Thursday, 30 May 13
TEAM WORKFLOW
BRANCHING, PULL REQUESTS & MERGING
• You can checkout each others branches to test
features that might be in progress.
• Once you have a branch with code that is ready to
get merged into master. Go to the GitHub page >
Branches > Click on the branch and then Click Pull
Request
• The Technical Lead should be responsible for
merging pull requests to keep everything streamlined.
Thursday, 30 May 13
RECAP
• git init
• git clone
• git add
• git commit
• git push
• git pull
• git status
• git merge
• git checkout
• pull requests
Thursday, 30 May 13
FURTHER READING
• A general guide to pushing/pulling
http://tinyurl.com/c3yr2v
• What to do when master is ahead of you
http://tinyurl.com/nh9jt2t
• Basic overview of branching and merging
http://tinyurl.com/btwgu79
• Setting up Git at home
https://help.github.com/articles/set-up-git
Thursday, 30 May 13
THE END!
ANY QUESTIONS? HIT ME UP
Thursday, 30 May 13

Contenu connexe

Tendances

Tendances (20)

Introduction to git and github
Introduction to git and githubIntroduction to git and github
Introduction to git and github
 
A prentation on github
A prentation on githubA prentation on github
A prentation on github
 
Git for Beginners
Git for BeginnersGit for Beginners
Git for Beginners
 
Git
GitGit
Git
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Building a µservice with Kotlin, Micronaut & GCP
Building a µservice with Kotlin, Micronaut & GCPBuilding a µservice with Kotlin, Micronaut & GCP
Building a µservice with Kotlin, Micronaut & GCP
 
Github Case Study By Amil Ali
Github Case Study By Amil AliGithub Case Study By Amil Ali
Github Case Study By Amil Ali
 
Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1Introduction to Git and GitHub Part 1
Introduction to Git and GitHub Part 1
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHub
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
 
Github basics
Github basicsGithub basics
Github basics
 
Git, GitHub and Open Source
Git, GitHub and Open SourceGit, GitHub and Open Source
Git, GitHub and Open Source
 
Git and GitHub crash course
Git and GitHub crash courseGit and GitHub crash course
Git and GitHub crash course
 
Git & GitHub
Git & GitHubGit & GitHub
Git & GitHub
 
Advance workshop on git
Advance workshop on gitAdvance workshop on git
Advance workshop on git
 

En vedette

En vedette (9)

The development workflow of git github for beginners
The development workflow of git github for beginnersThe development workflow of git github for beginners
The development workflow of git github for beginners
 
[2015/2016] Collaborative software development with Git
[2015/2016] Collaborative software development with Git[2015/2016] Collaborative software development with Git
[2015/2016] Collaborative software development with Git
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git and GitHub for Documentation
Git and GitHub for DocumentationGit and GitHub for Documentation
Git and GitHub for Documentation
 
My Git workflow
My Git workflowMy Git workflow
My Git workflow
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
 

Similaire à GitHub Talk - Cody Carnachan

3 Git
3 Git3 Git
Git Introductive
Git IntroductiveGit Introductive
Git Introductive
Adham Saad
 
Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...
fureigh
 

Similaire à GitHub Talk - Cody Carnachan (20)

Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010
 
3 Git
3 Git3 Git
3 Git
 
Git Basics
Git BasicsGit Basics
Git Basics
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
Git for standalone use
Git for standalone useGit for standalone use
Git for standalone use
 
Git and Github workshop
Git and Github workshopGit and Github workshop
Git and Github workshop
 
Git github
Git githubGit github
Git github
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Lagos GitHub Meetup - What is Git?
Lagos GitHub Meetup - What is Git?Lagos GitHub Meetup - What is Git?
Lagos GitHub Meetup - What is Git?
 
Git with the flow
Git with the flowGit with the flow
Git with the flow
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Git Introductive
Git IntroductiveGit Introductive
Git Introductive
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
GDSC Git event 2023.pptx
GDSC Git event 2023.pptxGDSC Git event 2023.pptx
GDSC Git event 2023.pptx
 
Version controll.pptx
Version controll.pptxVersion controll.pptx
Version controll.pptx
 
Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

GitHub Talk - Cody Carnachan

  • 1. GITHUB & A BIT ON WORKFLOW Thursday, 30 May 13
  • 2. WHAT IS SCM? SOURCE CODE MANAGEMENT • Storing versions of files • Good backup • Important when working in teams • Points to revert back to Thursday, 30 May 13
  • 3. SCM SYSTEMS SOME EXAMPLES • Mercurial SUPER QUICK, LARGE DEV-TEAMS, SIMPLE • Subversion WIDEST ADOPTION, CHECKING OUT FILES, CENTRAL SERVER • Git GROWING QUICKLY, SUPER FAST, DELTA CHANGES, GITHUB, AWESOME Thursday, 30 May 13
  • 4. GIT VS GITHUB • Distributed source code management system • Hosted solution to facilitate easy collaboration on Git repositories Thursday, 30 May 13
  • 5. WHY GIT? • Distributed • Super-fast • Lightweight • Server-less • Personal preference • GitHub Thursday, 30 May 13
  • 6. WHY GIT? • Distributed • Super-fast • Lightweight • Personal preference • GitHub Thursday, 30 May 13
  • 7. WHY GIT? • Distributed • Super-fast • Lightweight • Personal preference • GitHub Thursday, 30 May 13
  • 8. WHY GIT? • Distributed • Super-fast • Lightweight • Personal preference • GitHub Thursday, 30 May 13
  • 9. WHY GIT? • Distributed • Super-fast • Lightweight • Personal preference • GitHub Thursday, 30 May 13
  • 10. WHY GIT? • Distributed • Super-fast • Lightweight • Personal preference • GitHub Thursday, 30 May 13
  • 11. GITHUB, GITHUB, GITHUB MORE ON THIS MAGICAL TOOL • Git repository hosting • Web tool suite • Collaborative development • Social coding (forking) Thursday, 30 May 13
  • 12. INSTALLING GIT HANDS-ON #1 MAC <3 - Easy as pie WINDOWS Good luck https://help.github.com/articles/set-up-git Thanks GitHub, let’s visit: Thursday, 30 May 13
  • 13. GIT WORKFLOW $ cd ~/Desktop/ $ mkdir git cd is the unix command for ‘change directory’. ~/ is your home directory. mkdir is the unix command for ‘make directory’. The same thing as creating a new folder. Thursday, 30 May 13
  • 14. GIT WORKFLOW git init will turn the current folder into a git repository. Git will now monitor this folder and any files and sub-directories for changes $ cd ~/Desktop/ $ mkdir git $ cd git $ git init Thursday, 30 May 13
  • 15. GIT WORKFLOW git status tells you the current status of the repository (changed files etc) Now: open up your text editor and create a blank txt file. Save it in the same directory as your git repo. $ git init $ git status Thursday, 30 May 13
  • 16. GIT WORKFLOW git status will now tell you there are untracked files git add [filename] is used to add files to the stage for a commit $ git status $ git add hello.txt Thursday, 30 May 13
  • 17. WOAH, SLOW DOWN! SOME GIT TERMINOLOGY STAGE A SET OF “STAGED” CHANGES THAT WILL BE PART OF A COMMIT COMMIT A PERMANENT SNAPSHOT OFYOUR GIT REPOSITORY AT A GIVEN TIME Thursday, 30 May 13
  • 18. GIT WORKFLOW git commit will create a snapshot of your repository saving all staged changes We use the -m flag followed by a string to define a commit message. Keep in mind that unstaged changes won’t be saved. $ git status $ git add hello.txt $ git commit -m “Initial commit” Thursday, 30 May 13
  • 19. GIT WORKFLOW git status will show no changes 1. Make a change to hello.txt 2. Make a new file 3. Commit JUST the new file $ git status $ git add hello.txt $ git commit -m “Initial commit” $ git status Thursday, 30 May 13
  • 20. HOLD UP! What do you notice? Thursday, 30 May 13
  • 21. TEAM WORKFLOW USING GIT & GITHUB • Role-oriented AND random editing of files without fear of overwriting anyone else’s work • Branching off from the master (main) code base to work on individual features WITHOUT breaking the whole site • Multiple backups of the code-base • Ability to revert to ANY previous version of a file Thursday, 30 May 13
  • 22. ‘ADVANCED’ TERMINOLOGY PUSHING PUSHYOUR COMMITS TO THE UPSTREAM SERVER (GITHUB) PULLING PULL DOWN THE LATEST COMMITS FROM THE UPSTREAM SERVER (GITHUB) MASTER BRANCH MASTER IS THE DEFAULT BRANCH INYOUR REPOSITORY.THIS IS THE MAIN CODE BASE AND SHOULD AT ALL TIMES CONTAIN DEPLOYABLE CODE. BRANCHING CREATING ADDITIONAL BRANCHES OFF OF MASTER TO WORK ON INDIVIDUAL FEATURES Thursday, 30 May 13
  • 23. PUSHING & PULLING USING AN UPSTREAM SERVER (GITHUB) • In your teams: push and pull as often as possible • Before starting work on, always PULL • Try to use another communication tool (FB, Skype etc) to keep in touch when developing and tell eachother when you have made changes. Thursday, 30 May 13
  • 24. OH SHIT! SOMEONE EFFED’ UP •You probably went to push some commits without pulling from GitHub and now you have some screwed up, out of order repo. •Solving this problem can be a bitch so cross your fingers and hope for the best. Thursday, 30 May 13
  • 25. OH SHIT! THE SOLUTION • Run git pull. Git will force you to merge the changes but you will need to do this manually. • Run git merge. Git will merge your commits with the upstream commits into a new commit, then push. Thursday, 30 May 13
  • 26. BRANCHING SOME GIT AWESOMENESS • Branching should be used when you want to work on a specific feature • Give your branches descriptive names i.e. user-login or pretty-forms • Don’t try and make your branches all encompassing (keep them small and modular) Thursday, 30 May 13
  • 27. USING GITHUB HANDS-ON #2 http://github.com Go to ^ and make an account Thursday, 30 May 13
  • 28. TEAM WORKFLOW BRANCHING, PULL REQUESTS & MERGING • Get in your teams • The technical lead should create a repository on their account then go to settings and invite the other members of your team as collaborators. • Everybody grab the URL found on the repo page: Thursday, 30 May 13
  • 29. BRANCHING $ cd ~/Desktop/ $ git clone https://github.com/ codycarnachan/mds.git Let’s reset our directory to our Desktop. git clone is the command for cloning a repository. Make sure you put your own URL in; you won’t be able to clone repositories that you aren’t a collaborator on. Thursday, 30 May 13
  • 30. BRANCHING $ cd ~/Desktop/ $ git clone https://github.com/ codycarnachan/mds.git $ git checkout -b new-branch- name git checkout -b [branchname] is the command for creating a new branch and switching to it (or just switching if it already exists) Changes you make now will be independent to the master brach Thursday, 30 May 13
  • 31. BRANCHING $ cd ~/Desktop/ $ git clone https://github.com/ codycarnachan/mds.git $ git checkout -b new-branch- name Create a file with some text and then commit it. Note: There is a different format to push your new local branch to the upstream server: git push -u origin [branchname] Thursday, 30 May 13
  • 32. TEAM WORKFLOW BRANCHING, PULL REQUESTS & MERGING • You can checkout each others branches to test features that might be in progress. • Once you have a branch with code that is ready to get merged into master. Go to the GitHub page > Branches > Click on the branch and then Click Pull Request • The Technical Lead should be responsible for merging pull requests to keep everything streamlined. Thursday, 30 May 13
  • 33. RECAP • git init • git clone • git add • git commit • git push • git pull • git status • git merge • git checkout • pull requests Thursday, 30 May 13
  • 34. FURTHER READING • A general guide to pushing/pulling http://tinyurl.com/c3yr2v • What to do when master is ahead of you http://tinyurl.com/nh9jt2t • Basic overview of branching and merging http://tinyurl.com/btwgu79 • Setting up Git at home https://help.github.com/articles/set-up-git Thursday, 30 May 13
  • 35. THE END! ANY QUESTIONS? HIT ME UP Thursday, 30 May 13