Docsity

Git Version Control: Understanding the Importance and Building a System, Slides of Computer Science

Partial preview of the text

Download Git Version Control: Understanding the Importance and Building a System and more Slides Computer Science in PDF only on Docsity!

Git

(and some other stuff)

Pat Pannuto / Marcus Darden

Recapping last week

Any lingering administrative issues?

What's version control?

What's version control?

Why is it important?

And how might we build a version control

system?

Git-ing started (I'm so sorry)

first — init

making commits — add , commit

viewing work/history — status , log

Git-ing started (I'm so sorry)

first — init

making commits — add , commit

viewing work/history — status , log

Let's peek under the hood

History is a linked list

What's master , HEAD?

Where's the old versions?

Using git locally

Working Directory Staging Area Repository Local Machine git add my_file git res et my_file git res et --s oft HEAD^ git commit git res et HEAD^ git commit my_file

Collaborating with git

First, we have to talk just a little about branches

Why is git cool?

Let's debug a real-world problem

Phony is a ruby library for pretty-printing phone numbers. It's used by a

bunch of websites (AirBnB, ZenDesk, etc)

1. git clone https://github.com/floere/phony

US phone number

ruby -e 'require "./lib/phony"' -e 'puts Phony.format("17345551212")'

  • 1 (734) 555-

French phone number

ruby -e 'require "./lib/phony"' -e 'puts Phony.format("33123456789")' +33 1 23 45 67 89

Emergency phone number in the UK

ruby -e 'require "./lib/phony"' -e 'puts Phony.format("999")'

ruby -e 'require "./lib/phony"' -e 'puts Phony.format("999")'

Go back in time to when you know it worked

git checkout v1.9.

ruby -e 'require "./lib/phony"' -e 'puts Phony.format("999")'

Go back in time to when you know it worked

git checkout v1.9.

Search history for the problem

The git bisect command will help keep track of progress

git bisect start git bisect good git checkout master git describe git bisect bad

(magic)

git describe

ruby -e 'require "./lib/phony"' -e 'puts Phony.format("999")'

Go back in time to when you know it worked

git checkout v1.9.

Search history for the problem

The git bisect command will help keep track of progress

git bisect start git bisect good git checkout master git describe git bisect bad

(magic)

git describe

But I'm still lazy

ruby -e 'require "./lib/phony"' -e 'puts Phony.format("999")'

Go back in time to when you know it worked

git checkout v1.9.

Search history for the problem

The git bisect command will help keep track of progress

git bisect start git bisect good git checkout master git describe git bisect bad

(magic)

git describe

But I'm still lazy

git bisect run ruby -e 'require "./lib/phony"' -e 'puts Phony.normalize("+999")'

So what changed?

git log -p — or — github.com/floere/phony/commit/9b4234....

https://github.com/floere/phony/issues/

Closing remarks

You must use git for something non-trivial this

term

You should use version control for all your class projects

And I don't mean folder-copying

(I'm looking at you, freshman-year Pat)

Not in any programming classes?

Try using it for other homework

Deadline for this is Week 7 — Git II (Oct 19/21)