Git Fundamentals - pauby.com...GIT FUNDAMENTALS Open up a world of community and collaboration Paul...

Post on 29-Jun-2020

11 views 0 download

Transcript of Git Fundamentals - pauby.com...GIT FUNDAMENTALS Open up a world of community and collaboration Paul...

GIT FUNDAMENTALSOpen up a world of community and collaboration

Paul Broadwith@pauby

https://blog.pauby.com

French PowerShell Saturday

15 Septembre 2018 - #FrPwshSat2018

Merci à nos sponsors !!

WHO AM I?

• Senior Technical Engineer @ Chocolatey Software

• 25+ years in IT in the defence, government, financial services and nuclear industry sectors.

• Scottish PowerShell & DevOps User Group Founder

Paul Broadwith

QUESTIONS AT END –MAYBE?

AGENDA

• 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?

• Essential Git commands you need to know!

WHO IS THIS AIMED AT?

Level 100

Git

is not

GitHub

WHAT IS GIT?

WHAT IS GIT?│WHAT IS IT?

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

WHAT IS GIT?│WHAT IS IT?

Which means Git is:

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

WHAT IS GIT?│WHAT IS IT?

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_control

WHAT IS GIT?│WHAT IS IT?

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.

WHAT TOOLS DO I NEED?

TOOLS│CHOCOLATEY PACKAGE MANAGER

https://chocolatey.org

https://chocolatey.org/install

TOOLS│REQUIRED SOFTWARE

http://gitforwindows.org/

Git Tools

> choco install git -y

TOOLS│RECOMMENDED SOFTWARE

Git Credential Manager For Windows

Git Extensions

GitHub Pull Requests

posh-git

PSGit

WHO USES GIT?

WHO USES GIT?│COMPANIES & PROJECTS YOU KNOW

WHO USES GIT?│PROVIDERS & SOFTWARE

WHO USES GIT?│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)

WHO USES GIT?│VISUAL STUDIO CODE ON GITHUB

1561

717

104

49

Issues

Commits

Pull Requests

Authors

16 December 2017 to 16 January 2018

WHO USES GIT?│DSCRESOURCES REPOSITORY

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

WHO USES GIT?│PEOPLE LIKE YOU

Writers Websites

Developers, Coders

& ScriptersCI / CD,

Runbooks,

Cookbooks

WHY DO I NEED TO USE GIT?

WHY DO I NEED TO USE GIT?│POWERSHELL DEV

I write PowerShell …

… I’m not a developer

WHY DO I NEED TO USE GIT?│POWERSHELL DEV

If you write code …

… you are a developer

WHO USES GIT?│2017 GITHUB USE

https://octoverse.github.com/

47 Million Pull Requests

24 Million Developers

25.3 Million Active Repositories

1 Billion Commits

WHO USES GIT?│GITHUB REPO BY LANGUAGE

3,027,077

1,433,985

675,803

33,012

Javascript

Python

C#

PowerShell

12 September 2018

WHY DO I NEED TO USE GIT?│GIT HAS YOUR BACK

ChangeHistory

UndoMistakes Collaborate

CI / CD

Open Source

WHY DO I NEED TO USE GIT?│DON’T HIDE YOUR CODE

WHY DO I NEED TO USE GIT?│BEARDY DEV

HOW DOES GIT WORK?3 Stages

HOW DOES GIT WORK?│3 STAGES

Unstaged Staged Committed

> git status> git add <. | FILES>

> git commit –m ‘Message’

Change source files

Stage changed files

Commit changes

HOW DOES GIT WORK?│5 FUNDAMENTALS OF GIT

commit

pull requests

repository

fork *

branches

HOW DOES GIT WORK?│REPOSITORY

Just a folder where you store your project files

Repository / Repo – terminology - both used

myproject

HOW DOES GIT WORK?│SPECIAL REPOSITORY FILES

.git

History, index and other management files for Git

File and folder name patterns that Git should ignore

.gitignore

HIDDENDON’T

TOUCH!

HOW DOES GIT WORK?│BRANCHES

master branch

update-doc branch

dev branch

fix-memory-leak branch

HOW DOES GIT WORK?│PULL REQUEST

Allows review and discussion around those changes.

master branch

update-doc branch

Lets others know about a change you have made.

HOW DOES GIT WORK?│COMMIT

When one or more changes have been applied to a branch, it is called a …

Committed

> git commit –m ‘Message’

Commit changes

… commit

ESSENTIAL GIT COMMANDS YOU NEED TO KNOW!

ESSENTIAL GIT COMMANDS?│8 OF THEM

status?add+

pull

clone push

checkout

commit

remote

DEMO

ESSENTIAL GIT COMMANDS?│USEFUL COMMANDS

reset?

fetch merge

rebase?

HOW GIT WORKS│STANDARD GIT CYCLE

Push

Commit

Pull

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

> git push

AGENDA QUESTIONS

• 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?

• Essential Git commands you need to know!

Git is a Version Control System

Git Tools, Credential Manager, Git Extensions (& Git Lens?)

EVERYBODY and it will help you write better code!

5 fundamentals, 3 stages

8 commands

QUESTIONS?

Congratulations!

You’re now a git !git

QUESTIONS?

pauby.com

@pauby

github.com/pauby

linkedin.pauby.com

Paul Broadwith

pau.by/talks