collaborative development with git

58
Introduction to collaborative development with git Patrick JL Laso @jl_laso www.patricklaso.com http://www.slideshare.net/jlaso Rev.1.0

Upload: joseluis-patrick-laso

Post on 21-Jul-2015

83 views

Category:

Internet


2 download

TRANSCRIPT

Page 1: Collaborative development with git

Introduction to collaborative

development with gitPatrick JL Laso

@jl_laso www.patricklaso.com

http://www.slideshare.net/jlaso

Rev.1.0

Page 2: Collaborative development with git

Are you a solo developer ?Even if you are alone, you can improve your productivity.

Page 3: Collaborative development with git

How not work alone

FTP

Page 4: Collaborative development with git

Why not ?

Page 5: Collaborative development with git

• You cannot control versions

• You cannot recover last operative version

• You have to upload all files to be sure that the production version works fine as local works

Page 6: Collaborative development with git

Or a team ?Some order is needed to go ahead

Page 7: Collaborative development with git

Ready to jump ?Collaborative development with git

Page 8: Collaborative development with git

Well, let's go then!

Page 9: Collaborative development with git

What is GIT ?

Page 10: Collaborative development with git

What is GIT ?GIT is a source control management (SCM) that

allows developers to have controlled all versions and premises about collaboration

between the team members.!Once you now how it works rarely you will

think in work in other way. The principle is that all the sources reside in a central repository and all members have a copy of it, in local.

Through commands the changes are uploaded/downloaded from/to central repository.

Page 11: Collaborative development with git

Let's see how works

Page 12: Collaborative development with git
Page 13: Collaborative development with git
Page 14: Collaborative development with git
Page 15: Collaborative development with git
Page 16: Collaborative development with git
Page 17: Collaborative development with git

But … this is all ?

Page 18: Collaborative development with git

But … this is all ?

NO

Page 19: Collaborative development with git

Roberta John Julia

Development team

Page 20: Collaborative development with git

master develop

Roberta John Julia

Development team

Page 21: Collaborative development with git

master develop

Roberta John Julia

Development team

production server

master

Page 22: Collaborative development with git

master develop

Roberta John Julia

Development team

Page 23: Collaborative development with git

master develop

Roberta John Julia

Development teamgit fetch origin develop:develop

Page 24: Collaborative development with git

master develop

Roberta John Julia

Development teamgit fetch origin develop:develop

Page 25: Collaborative development with git

master develop

Roberta John Julia

Development teamgit fetch origin develop:develop

master develop

Page 26: Collaborative development with git

master develop

Roberta John Julia

Development teamgit fetch origin develop:develop

master develop

some work in local

Page 27: Collaborative development with git

master develop

Roberta John Julia

Development teamgit fetch origin develop:develop

master develop

some work in local

Page 28: Collaborative development with git

master develop

Roberta John Julia

Development teamgit fetch origin develop:develop

master develop

some work in local

git push origin develop

Page 29: Collaborative development with git

Best practicesDon't use always master branch

Page 30: Collaborative development with git

• The develop branch is the base • We create a feature branch in order to

develop a new functionality • We can test this functionality locally or in

other pre-staging server • Once all it's OK we have to merge this

feature branch to develop branch, and the deploy in staging server to test the whole product

• Lastly we have to create a release to merge changes on master branch and finally deploy in production

Roadmap

Page 31: Collaborative development with git

• The develop branch is the base • We create a feature branch in order to

develop a new functionality • We can test this functionality locally or in

other pre-staging server • Once all it's OK we have to merge this

feature branch to develop branch, and the deploy in staging server to test the whole product

• Lastly we have to create a release to merge changes on master branch and finally deploy in production

Roadmapgit checkout -b feature/new-functionallity

Page 32: Collaborative development with git

• The develop branch is the base • We create a feature branch in order to

develop a new functionality • We can test this functionality locally or in

other pre-staging server • Once all it's OK we have to merge this

feature branch to develop branch, and the deploy in staging server to test the whole product

• Lastly we have to create a release to merge changes on master branch and finally deploy in production

Roadmapgit checkout -b feature/new-functionallity

git checkout develop !git merge —no-ff feature/new-functionallity

Page 33: Collaborative development with git

master

developfeature

release

git checkout -b new-branchgit merge —no-ff branch-to-mergegit push origin local-branch

git fetch origin feature:feature

sysadmin, jenkins, automatic deploy, etc

Page 34: Collaborative development with git

Some commandsFirst learn to use console

Page 35: Collaborative development with git

Some git commandsclone git clone url folder

branches list local branches: git branch remote branches: git branch -r

get branch git fetch origin remote-branch:local-branch

status git status

stashgit stash git stash list git stash pop git stash clear

processgit add -A git commit -e git pull origin git push origin branch

Page 36: Collaborative development with git

SamplesHow to use git in the real world

Page 37: Collaborative development with git

Create a repo in our server• our server has the IP 192.168.1.1

• our git user is gituser

• we have to create a ssh relation*

• git init --bare /var/git/sample.git

Page 38: Collaborative development with git

Clone in local the repo• git clone [email protected]:/var/git/sample.git /home/user/projects/sample

Page 39: Collaborative development with git

Create local repository• cd /home/user/projects/sample

• git init

Page 40: Collaborative development with git

Assign remote in existing local repository

• cd /home/user/projects/sample

• git remote add origin [email protected]/var/git/sample.git

Page 41: Collaborative development with git

Commit all changes in local

• git add -A

• git commit -m "message to commit"

Page 42: Collaborative development with git

Update local from remote• git pull origin

all the changes in local files have to be committed or stashed before to use pull.

Page 43: Collaborative development with git

Save changes in clipboard (stash)

• git stash

stash

Page 44: Collaborative development with git

See stash's contents• git stash list

stash

Page 45: Collaborative development with git

Recover last stash• git stash apply # apply changes w/o erasing from stash

• git stash pop # extracts and apply contents from stash

stash

Page 46: Collaborative development with git

Clear contents of stash• git stash clear

stash

Page 47: Collaborative development with git

Update remote from local• git push origin branch

before to use push we have to use pull in order to update our local repo with content of remote and resolve posible conflicts first.

Page 48: Collaborative development with git

Create branch from existing

• git checkout -b new-branch

Page 49: Collaborative development with git

Merge branch with current

• git merge --no-ff branch-to-merge

Page 50: Collaborative development with git

commercial gitservers that use git

Page 51: Collaborative development with git

github.com

• github.com allows to create repositories through its graphic interface

• we can get the url to clone from page just created

• then is as you have a private server

Page 52: Collaborative development with git

github.com

• github.com allows to create repositories through its graphic interface

• we can get the url to clone from page just created

• then is as you have a private server

Page 53: Collaborative development with git

Create projects in github.comWe can create public repositories for free

Page 54: Collaborative development with git

bitbucket.org

• bitbucket.org allows to create repositories through its graphic interface

• we can get the url to clone from page just created

• then is as you have a private server

Page 55: Collaborative development with git

bitbucket.org

• bitbucket.org allows to create repositories through its graphic interface

• we can get the url to clone from page just created

• then is as you have a private server

Page 56: Collaborative development with git

Create projects in bitbucket.orgWe can create private or public repositories

Page 57: Collaborative development with git

More infohttp://git-scm.com/documentation!

!https://training.github.com/kit/downloads/github-git-cheat-sheet.pdf!

Page 58: Collaborative development with git

Thank youPatrick JL Laso

@jl_laso www.patricklaso.com

http://www.slideshare.net/jlaso