git 101

38
Git 101 FreeFriday @ Teipir

Upload: dimitris-tsironis

Post on 29-Nov-2014

354 views

Category:

Technology


0 download

DESCRIPTION

A basic intro to Git for 0xFreeFridays meetups at Technological Educational Institute of Piraeus

TRANSCRIPT

Page 1: Git 101

Git 101FreeFriday @ Teipir

Page 2: Git 101

Real quick...

Page 3: Git 101

Free Fridays

Discuss about technology and stuff

Learn new things and stay up-to-date

Get better at what we do

Enrich our education

Page 4: Git 101

Dimitris Tsironis

Front-end Engineer at BugSense,

JavaScript lover || hater,

Open-source & (Coffee)Script addict,

Technology afficcionado

Page 5: Git 101

Source Control Management

Keep your code organized in repositories

Enhance contributing

Source versioning

Page 6: Git 101

GitDistributed Version Control System (DVCS)

Page 7: Git 101

GitCreated by Linus Torvalds [2005]

Written (mostly) in C and Shell

Page 8: Git 101

Why distributed?

Every developer gets a copy of the repo

Make your contributions really fast

Work offline

Page 9: Git 101

Git installation

sudo apt-get install git [Ubuntu]

brew install git [OSX]

http://bit.ly/14Gqzyp [Windows]

Page 10: Git 101

Creating a repository

$ mkdir -p ~/gitff/lecture1

$ cd ~/gitff/lecture1

$ git init

Page 11: Git 101

Now your folder is a git repository

Page 12: Git 101

Start coding!or whatever

Page 13: Git 101

Write some code

Create a text file (touch readme.txt)

Add your name inside the file

Page 14: Git 101

Cool story bro!

but how can I update my repo?

Page 15: Git 101

CommitA set of changes

Page 16: Git 101

The staging areaAll the modified/added/deleted files that are

going to be commited

Page 17: Git 101

git status# On branch master## Initial commit## Untracked files:# (use "git add <file>..." to include in what will be committed)## readme.txtnothing added to commit but untracked files present (use "git add" to track)

Page 18: Git 101

Add readme to stage

git add readme.txt

This command adds readme.txt (or changes in readme.txt) to staging area

Page 19: Git 101

Alternative adding all files to stage

git add --all

This command adds (add) all (deleted/created/modified) files to staging area

Page 20: Git 101

git status# On branch master## Initial commit## Changes to be committed:# (use "git rm --cached <file>..." to unstage)## new file: readme.txt#

Page 21: Git 101

Commit changes

git commit -m “Initial Commit”

This command creates the commit containing the staged changes

Page 22: Git 101

Now add your email to readme.txt

Page 23: Git 101

How can I get my code to the web?

Page 24: Git 101

Github (Hosted)

Bitbucket (Hosted)

GitLab (Private)

And may others

Page 25: Git 101

Githuba web-based hosting service

for software development projects that use Git

Written in Ruby on Railsand Erlang

Running since 2008

Page 26: Git 101

Creating a new Github Repository

Page 27: Git 101
Page 28: Git 101
Page 29: Git 101

The remote (origin)

The git path to remote repository (usually called origin)

Page 30: Git 101

Add remote to local repository

git remote add origin your_remote

This command adds a remote to a remote repository

Page 31: Git 101

git remote -v

Show my remotes

Page 32: Git 101

Pushpushing commits to remote repository

Page 33: Git 101

Push changes to remote repository

git push origin master

We will only use master branch for the time being

Page 34: Git 101

Pullpulling commits from remote repository

Page 35: Git 101

Pull changes from remote repository

git pull origin master

We will only use master branch for the time being

Page 36: Git 101

CloneGet a copy of a repository

Page 37: Git 101

Cloning a repository

$ cd

$ git clone https://github.com/FreeFriday/my_first_repo.git angels_first_repo

$ cd angels_first_repo

$ ls -l

Page 38: Git 101

Thanks!@tsironakos