Top Banner
Paul Broadwith @pauby https://blog.pauby.com Git Fundamentals Open up a world of community and collaboration
50

Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Jul 10, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Paul Broadwith@pauby

https://blog.pauby.com

Git FundamentalsOpen up a world of community and collaboration

Page 2: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial
Page 3: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

• Paul Broadwith, Glasgow, Scotland

• 25+ years in defence, government, financial sectors

• Lead Engineer on Boxstarter and Chocolatey cChoco DSC Resource

Who Am I?

Page 4: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Questions At The End?

Page 5: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

In This Session

• What actually is Git?

• What tools do I need for Git?

• Who is using Git and why do I need to use it?

• How does Git work?

• Git commands you need to know!

• What is a Pull Request and what they are used for;

• How to work with Open Source projects using Git;

Page 6: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Who Is This Aimed At?

Level 100

Page 7: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial
Page 8: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Git

is not

GitHub

Page 9: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

What Is Git?

Page 10: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

What Is Git?

Wikipedia defines Git as:

Git is a version control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source code management in software development, but it can be used to keep track of changes in any set of files. As a distributed revision control system it is aimed at speed, data integrity, and support for distributed, non-linear workflows.

• https://en.wikipedia.org/wiki/Git

Page 11: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

What Is Git?

Which means Git is:

Git is a version control system for tracking changes in computer files. It is aimed at speed and data integrity.

Page 12: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

What Is Git?

Wikipedia defines Version Control System as:

… version control is the management of changes to documents, computer programs, large web sites, and other collections of information. Changes are usually identified by a number or letter code, termed the "revision number“ … Each revision is associated with a timestamp and the person making the change. Revisions can be compared, restored, and with some types of files, merged.

• https://en.wikipedia.org/wiki/Version_contro

Page 13: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

What Is Git?

Which means a version control system is:

Version control is the management of changes to collections of information. Changes are identified by a number associated with a timestamp and the person making the change.

Page 14: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

What Tools Do I Need?

Page 15: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Recommended Software

https://chocolatey.org

https://chocolatey.org/install

Page 16: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Required Tools

Git Tools

> choco install git -y

https://gitforwindows.org/

https://git-scm.com/download/mac

> apt install git-all

Page 17: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Recommended Tools

Git Credential Manager For Windows

Git Extensions

GitHub Pull Requests

posh-git

PSGit

Page 18: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Who uses Git?

Page 19: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Companies & Projects You Know

Page 20: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Git Providers & Software

Page 21: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Microsoft Windows & GVFS

8421

2500

4352

1760

Code Pushes (per day)

Pull Requests (per day)

Active Branches

Windows Builds (per day)

https://blogs.msdn.microsoft.com/bharry/2017/05/24/the-largest-git-repo-on-the-planet/

As at May 2017 (Using GVFS)

Page 22: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

DSCResources Repository Statistics

https://blogs.msdn.microsoft.com/powershell/2018/09/13/desired-state-configuration-dsc-planning-update-september-2018/

Since 1 January 2018

475 Pull Requests

300 Closed Issues

Page 23: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Who Uses Git?

Writers Websites

Developers, Coders& ScriptersCI / CD,

Runbooks,Cookbooks

Page 24: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Why Do I Need To Use Git?

Page 25: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

If you write code …

… you are a developer

Page 26: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

2017 GitHub Use

https://octoverse.github.com/

47 Million Pull Requests

24 Million Developers

25.3 Million Active Repositories

1 Billion Commits

Page 27: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Git Has Your Back

ChangeHistory

UndoMistakes Collaborate

CI / CD

Open Source

Page 28: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial
Page 29: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Even The Beards Use It

Page 30: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

How Does Git Work?The 3 Stages Of Git

Page 31: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

8 Essential Git Commands

status?

add+ pull

clone

push

checkoutcommit

remote

Page 32: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

The 3 Stages

Unstaged Staged Committed

> git status> git add <. | FILES>

> git commit –m ‘Message’

Change source files

Stage changed files

Commit changes

Page 33: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

The 5 Fundamental Building Blocks Of Git

commit

pull requests

repository

fork *

branches

Page 34: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

What Is A Repository?

Just a folder where you store your project files

Repository / Repo – terminology - both used

myproj

Page 35: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

How Do Branches Work?

master branch

update-doc branch

dev branch

fix-memory-leak branch

Page 36: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

What Is A Commit?

When one or more changes have been applied to a branch, its called a … commit

Committed

> git commit –m ‘Message’

Commit changes

Page 37: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

What Is A Fork?

cool-project my/cool-project

cool-project fork

repository link

Forking a repo is simply creating a linked copy of that repository. The link allows changes to be pulled or pushed to the original repository.

Page 38: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

What Is A Pull Request?

Allows review and discussion around those changes.

master branch

update-doc branch

Lets others know about a change you have made.

Page 39: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Essential Git Commands

Page 40: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

DEMO

Our First Pull Request

Page 41: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Git Cycle

Push

Commit

Pull

> git pull > git add .> git commit –m “Initial commit”

> git push

Page 42: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Pull Request Flow

master branch

dev branch createdfrom master

commit code

submit pull request

dev branch merged to master

review changes

> git checkout –b dev> git add .> git commit –m “msg”> git push

Page 43: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial
Page 44: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial
Page 45: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Summary

• We learned what Git is and where it came from;

• What tools are needed to work with Git;

• Who is using Git and why I need to use it!

• Fundamental Git commands;

• The three stages of Git;

• What a pull request is, why we use them and how to use it to

work with Open Source projects;

Page 46: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Congratulations!

You’re now a git !git

Page 47: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Questions?

Page 48: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

DATA:Scotland

Speaker Scholarship

Inclusion – Diversity – Community

bit.ly/ds-

speaker

Page 49: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial
Page 50: Git Fundamentals - pauby.com · Git Fundamentals Open up a world of community and collaboration • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial

Thank You!

linkedin.com/in/paulbroadwith

pau.by/talksPaul Broadwith

pauby.com

@pauby

github.com/pauby