gittalk



gittalk

0 0


gittalk

A Git Introduction

On Github michaelsergio / gittalk

Setup

# You should set these two:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"

# Optional, but recommended:
git config --global color.ui "auto"

# Optionally, pick one editor to use: 
git config --global core.editor "nano"        # Default, if you do nothing.
git config --global core.editor "gedit -w -s" # Recommended option.
git config --global core.editor "vim"  
git config --global core.editor "emacs"

Setup up a GitHub account if you don't already have one: www.github.com

Give people time to get settled. They should run this if have they time.

Disclaimer:

I tend to talk really fast when I get excited, may use magical shortcuts and hotkeys without thinking about it, so if I do something you don't understand:

PLEASE tell me to "slow down and explain yourself!"

That being said, I like to keep things informal so please ask questions during the talk.

Git and Github

Introduction to Source Control

Michael Sergio

Show of hands Range: Seniors, Juniors, Sophmores, Freshman, Grads, CS,SE,non majors? How many have used Git before. Github? * Worked on coding projects together.

Problem 1:

You have code that works.

Now you have to implement a new feature.

After changing a few things, nothing works anymore.

What do you do?

That's what the Undo button is for. But what about code from 6 months ago. Even 6 hours ago. 6 minutes ago - new feature. Concept of revision may be good here. Working on multiple copies of code.

Problem 2:

You're working on a project with someone.

You make some changes.

How do you give those changes back?

USB, Dropbox.

Possible Solutions to Problem 2.

Carrier Pidgeon (RFC 1149)

Dropbox

Sneakernet - USB

Never underestimate the bandwidth of a station wagon full 
of tapes hurtling down the highway.
                                    - Andrew S. Tanenbaum

How do you put the data back together so that it works?

A Standard for the Transmission of IP Datagrams on Avian Carriers

Better Tools - A History

1974 Douglas McIlroy writes diff for Unix 5th Edition.

--- /path/to/original''timestamp''
+++ /path/to/new''timestamp''
@@ -1,3 +1,9 @@
+This is an important +notice! It should therefore be located at
+the beginning of this document!
+
This part of the document has stayed the same from version to
@@ -5,16 +11,10 @@
be shown if it doesn't change.  Otherwise, that would not be helping to
-compress the size of the changes.
-
-This paragraph contains
-text that is outdated.
-It will be deleted in the
-near future.
+compress anything.

1985 Larry Wall writes patch for sending diffs through networks.

Not a new problem. diff can also be called a delta. or a difference in files. patch takes those diff files and updates your current files. In 1985 networks, you didn't want to send a whole file.

History

  • 1972 SCSS - Source Code Control System - Bell Labs
  • 1982 RCS - Revision Control System
  • 1986 CVS - Concurrent Versions System
  • 2000 SVN - Subversion
  • 2002 DCVS - Distributed Concurrent Versions System
  • 2005 Bazaar
  • 2005 Mercurial
  • 2005 Git
These terms are used interchangeably now a days. But what happened in 2005 with all these

Problem 3

You're in charge of a project used by millions of users.

You receive thousands of patches per release.

You don't trust everyone.

You're Finnish.

What doesn't work

Centralized Workflow

Push and Pull from Central Repository

Define Repository of code. Define: push, pull. Not a bad model. Used by SVN. Problem: Who decides merges?

Distributed Workflow

Developer pulls a fork from the Blessed Repo. Developer commits changes to private repo. Developer pushes to their own public repo. Integration Manager pulls from each developers public repo. When well tested, manager pushes back to blessed repo. Every developer has their own separate branch.

Linux Workflow

For the Linux Kernel, different sub-systems have their own maintainers: networking, CPU, power, all the various drivers, etc...

You have the same structure as a distributed workflow but with more social structure.

Why Use A Distributed System?

Must get forking and merging right

Otherwise everything falls apart.

Development Workflow

Development Workflow

No title on this slide

Got It?

Good.

Lets do it!

https://github.com/michaelsergio/purrfect

Pull Request

https://github.com/blog/1124-how-we-use-pull-requests-to-build-github

How GitHub uses GitHub internally.

Staging

Git Ettiquite

  • If itâs not in source control, it doesn't exist!
  • Commit early, commit often!
  • Always look at your changes before committing them.
  • Compilation output does not belong in source control. Use .gitignore files!
  • Remember the axe-murderer when writing commit messages.

Applications of GitHub

  • Package Mangers
  • Continious Integration
  • Discover new projects and tools.
  • Click Explore on the GitHub main page for more.
  • https://github.com/explore

Beyond Code

Continuous Integration

You should not ever edit code directly on a server!

Push code to a remote service.

Have it tested and deployed automatically.

Etsy deploys more than 50 times a day.

Etsy uses Jenkins as CI tool.

Git is a tool

Professionals Invest in their tools!

Learn your Unix tools, your Text Editor, your Source Control, your scripting languages.

Don't be afraid!

"Civilised tool for a civilized age" - some guy on the internet

You may not always use the same tool.

Why do we use version control?

To protect us from ourselves.

Software is complex, every part is moving at once. Always use it!

Appendix

Add anything else that doesn't fit below.

Contributing Ettique

  • Pay attention to style guides used.
  • Always include a README.md!
  • Your README should always include how to build and run your project.CommonMark

Software Licenses

TLDR Legal

As a professional you should know the basic differences.

Why is Git so fast?

It's a DAG

Directed Acyclic Graph

Learn your data structures!

Questions?

References

Tutorials

Books

Links

History of SCM

Giveaway!

Homework, do it right now. If you have a side project in mind or an idea, go to your GH page. Create a new repo. Does it have a name, name it now. Otherwise use the default repo name it gives you. By the end of the week, start something.