43
Celestine Omin Software Engr @ Konga Maintainer of NSEFinance @cyberomin @nnekaukpanah's husband.

Lagos GitHub Meetup - What is Git?

Embed Size (px)

DESCRIPTION

Presentaion done at the Lagos GitHub Meetup

Citation preview

Page 1: Lagos GitHub Meetup - What is Git?

Celestine OminSoftware Engr @ KongaMaintainer of NSEFinance@cyberomin@nnekaukpanah's husband.

Page 2: Lagos GitHub Meetup - What is Git?

What is git?

Git is a distributed revision control and source code management (SCM) system with an emphasis on speed, data integrity, and

support for distributed, non-linear workflows.Wikipedia

Page 3: Lagos GitHub Meetup - What is Git?

Uses

l (Documet) Version management

Page 4: Lagos GitHub Meetup - What is Git?

Who is using it?

Page 5: Lagos GitHub Meetup - What is Git?

History

l Started by Linus Torvaldsl Launched in '05l Replacement for BitKeeper to manage Linux kernel

source code

Page 6: Lagos GitHub Meetup - What is Git?

Statistics

Github launched in 2008 to host Git repositories2009: over 50,000 repos, over 100,000 users2011: over 2 million repos, over 1 million users

Page 7: Lagos GitHub Meetup - What is Git?

Let us begin

Installation http://git-scm.com

Page 8: Lagos GitHub Meetup - What is Git?

Configuration

l $ git config –global user.name Fistname Surnamel $ git config –global user.email [email protected]

Page 9: Lagos GitHub Meetup - What is Git?

$ git init

Page 10: Lagos GitHub Meetup - What is Git?

l Make changesl Add the changes to staging indexl git add [filename]

l Commit it to the repositoryl git commit -m „This is an initial commit“

Page 11: Lagos GitHub Meetup - What is Git?

Enough Talk

DEMO

Page 12: Lagos GitHub Meetup - What is Git?

Best Practises

l Write meaningful commit messagesl Fixed redirection issue. This happens when a user does not select

Remember Me

l Keep commit messages short. 70 words should be just fine. Write as though you were tweeting :-)

Page 13: Lagos GitHub Meetup - What is Git?

$ git logcommit 330ec85cb900530edbfa0ac73519f29b4150e436

Author: Firstname Surname <[email protected]>Date: Wed Apr 23 02:15:47 2014 +0530

Fixed login redirection issue

Page 14: Lagos GitHub Meetup - What is Git?

More of - git log

l git log – [(init) limit] – git log -3 – Return last 3 commits

l git log –since=“2013-04-05“l git log –until=“2013-04-05“l git log –author=“author name“l git log –grep=“Init“ - Every commit with the word Init

Page 15: Lagos GitHub Meetup - What is Git?

Git's Underlying Concept

Page 16: Lagos GitHub Meetup - What is Git?
Page 17: Lagos GitHub Meetup - What is Git?

Ignoring files

.gitignore

Page 18: Lagos GitHub Meetup - What is Git?

l Images/ - Everything under the image directory

l *.log – Ignore all my log filesl * ? [aeiou] [0-9] – Even regular expression

Page 19: Lagos GitHub Meetup - What is Git?

Branches

What are branches?

Page 20: Lagos GitHub Meetup - What is Git?

Type of branches

l Masterl Your branch

Page 21: Lagos GitHub Meetup - What is Git?

Creating a branch

$ git branch admin$ git checkout admin

Page 22: Lagos GitHub Meetup - What is Git?

Compact method

git checkout -b admin

Page 23: Lagos GitHub Meetup - What is Git?

Merging Branches

$ git checkout master$ git merge admin

Page 24: Lagos GitHub Meetup - What is Git?

All my branches

$ git branchadmin

* masterNotice the * on the master branch?

Page 25: Lagos GitHub Meetup - What is Git?

Pruning branches

$ git branch -d admin

Page 26: Lagos GitHub Meetup - What is Git?

Stashes

What are stash?

Page 27: Lagos GitHub Meetup - What is Git?

Stash Operations

$ git stash save “message”Notice we don't provide -m option

Page 28: Lagos GitHub Meetup - What is Git?

Stash Operations – List Stashes

$ git stash liststash@{0}:On branch_name: message

Page 29: Lagos GitHub Meetup - What is Git?

Stash Operations - Show

$ git stash show stash@{0}

Page 30: Lagos GitHub Meetup - What is Git?

Stash Operations - Pop

$ git stash pop stash@{0}

Page 31: Lagos GitHub Meetup - What is Git?

Stash Operations - Delete

$ git stash drop stash@{0}

Page 32: Lagos GitHub Meetup - What is Git?

l Questions?

Page 33: Lagos GitHub Meetup - What is Git?

Remotes

GitHubhttp://github.com

Page 34: Lagos GitHub Meetup - What is Git?

What is GitHub?

l GitHub is a Git repository web-based hosting service which

offers all of the distributed revision control and source

code management (SCM) functionality of Git as well as

adding many of its own features.

Page 35: Lagos GitHub Meetup - What is Git?

Working with remotes

l Go to http://github.com, l create a new repository and that's it.

Page 36: Lagos GitHub Meetup - What is Git?

Adding remotes

git remote add origin [email protected]:user/repo.git

Page 37: Lagos GitHub Meetup - What is Git?

Adding remotes

git remote add origin [email protected]:user/repo.git

Page 38: Lagos GitHub Meetup - What is Git?

Checking Remotes

git remote -v

Page 39: Lagos GitHub Meetup - What is Git?

Pushing to GitHub

$ git push origin masterAssuming you have multiple branches. In Git 2.0 you

can use git push alone

Page 40: Lagos GitHub Meetup - What is Git?

Pulling from GitHub

$ git pull origin master – Assuming you have multiple branches

Page 41: Lagos GitHub Meetup - What is Git?

Typical Workflow

$ git checkout master $ git fetch$ git merge origin/master$ git checkout -b contact_page$ git add feedback.html$ git commit -m “Added feedback form”

Page 42: Lagos GitHub Meetup - What is Git?

Questions?

Page 43: Lagos GitHub Meetup - What is Git?

Thank You

The WifeCcHubGitHub

Ciara, Luke, DanishFarouq, Jerry, Zainab, Jide, Jim

Audience