Git[hub] – For dummies – Outline



Git[hub] – For dummies – Outline

0 0


github-for-dummies

A quick git and github introduction

On Github andou / github-for-dummies

Git[hub]

For dummies

Created by Antonio Pastorino / a.pastorino@bitmama.it

Outline

  • What are git and github
  • How they work
  • How can I use them

Definitions

“Git (/ɡɪt/) is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows.”

so what??

“Revision control, also known as version control and source control, is the management of changes to documents, computer programs, large web sites, and other collections of information.”

clear, uh?

Survey

Who already knows Git?

Who knows any of these?

  • SVN
  • CVS
  • Mercurial

Why should I use version control?

“An elegant weapon for a more civilized age.”

Look, it's not useful if I

  • Do not have other people working on the code.
  • Do not plan on letting others have the code.
  • Isn't it an overhead?

Well, have you ever

  • made a change to code, realised it was a mistake and wanted to revert back?
  • lost code or had a backup that was too old?
  • had to maintain multiple versions of a product?

And if you wonder to

  • see the difference between two (or more) versions of your code?
  • prove that a particular change broke or fixed a piece of code?
  • review the history of some code?

Or even

  • submit a change to someone else's code?
  • share your code, or let other people work on your code?
  • see how much work is being done, and where, when and by whom?

And, last but not least

  • wanted to experiment with a new feature without interfering with working code?

Version control systems

Local

Centralized

Distributed

About Git

Desing Goals

  • Speed
  • Simple Design
  • Strong support for thousands of parallel branches
  • Fully distributed
  • Able to handle larges projects like Linux kernel effectively
  • Ensure integrity

Git is a filesystem

Git thinks of its data more like a set of snapshots of a mini filesystem.

Git has integrity

  • Everything is checksummed
  • References are SHA-1

986da33f0edea8f13b8dee427262ffd1bce0a4c4

Git doesn't delete

  • generally only adds data
  • if you mess up, you can usually recover your stuff
  • not for everyone, though

Git states & workflow

Three states

  • Modified
  • Staged
  • Committed
  • Pushed?

Workflow

File status lifecycle

About Github

  • web-based Git repository hosting service
  • offers all of the distributed SCM functionalities of Git
  • adds new features

New features

  • web-based graphical interface
  • desktop & mobile integration
  • access control
  • pull requests
  • and more (wikis, task management, bug tracking, etc.)

Installing Git

Windows

msysgit: https://msysgit.github.io/

Linux

Debian

$ aptitude install git

Ubuntu

$ apt-get install git

Centos

$ yum install git

Arch

$ pacman -S git

OS X

$ brew install git

Also developer tools should be ok...

Configuring Git

Identity

$ git config --global user.name "Peter Parker"$ git config --global user.email peterparker@bitmama.it

Editor

$ git config --global core.editor nano

Colors

$ git config --global color.ui true

Configurations are in ~/.gitconfig

Using Github

Join github

https://github.com/join

Private/Public Key

SSH keys are a way to identify trusted computers, without involving passwords.

https://help.github.com/articles/generating-ssh-keys/

Starting with Git

Initizialize your project

$ git init

Or clone it

$ git clone https://github.com/andou/github-for-dummies.git

What's up?

$ git status

Decide what is relevant

$ git add file1 file2 ...$ git commit

What did I just modify

$ git diff

What happened?

$ git log

I've screwed everything up....

$ git reset

.gitignore

sample

.DS_Store*.log/build//doc/[abc]*.txt.sass-cache
            
  • Blank lines or lines starting with # are ignored
  • End pattern with slash (/) to specify a directory
  • Negate pattern with exclamation point (!)

Remotes

  • Other clones of the same repo
  • Can be more than one
  • There are default remotes for push and pull
  • Github is a remote
$ git remote -vorigin	https://github.com/andou/github-for-dummies.git (fetch)origin	https://github.com/andou/github-for-dummies.git (push)

Push to remote

$ git push <remote>  <branch>

Pull from remote

$ git pull <remote>  <branch>

Tags

  • specify important points in history
  • tipically release points

Lightweight tags

$ git tag v0.0.1

Annotated tags

$ git tag -a v0.0.1 -m 'this is my tag'

Branches

  • are "pointers" to commit
  • identify streams of development
  • they can diverge from each other
  • they can be merged

Diverging branches

Merged branches

Merging

  • There are different auto-merge strategies
  • If it fails, you'll have to fix by hand
  • Mark conflicts as resolved and trigger a merge commit

Branch management

Create new branch

$ git branch iss53
$ git checkout -b iss53 master

Switch Branch

$ git checkout iss53

Delete Branch

$ git branch -d iss53

Stashing

Move changes to a separate "stash".

$ git stash save$ git stash list$ git stash apply

Workflow

Progressive stability

Topic branches

References

More references

Some more...

Not enough??

THE END

- Link to this presentation - Source code of this presentation

Legal

License

CC BY-SA 3.0

Attribution
0
Git[hub] For dummies Created by Antonio Pastorino / a.pastorino@bitmama.it