git & gitflow

24
Foobarsystem Co.,LTD @nolifelover Git & Gitflow

Upload: nolifelover-earn

Post on 06-May-2015

227 views

Category:

Software


1 download

DESCRIPTION

Softskill training

TRANSCRIPT

Page 1: Git & gitflow

Foobarsystem Co.,LTD

@nolifelover

Git & Gitflow

Page 2: Git & gitflow

Foobarsystem Co.,LTD

What is Git?

● Git is VCS, SCM ● Distributed Version Control Systems

(DVCSs) ● Other SVN, Mercurial

Page 3: Git & gitflow

Foobarsystem Co.,LTD

What is DVCSs

Distributed Version Control Systems

Page 4: Git & gitflow

Foobarsystem Co.,LTD

What can git do?

● Tracking code changes● Branching● Tagging● Merging● Rollback● ...

Page 5: Git & gitflow

Foobarsystem Co.,LTD

How does it work?

● Tracking changes in files.● Committing changes.● Working directory, Staging area and the

remote repository● .git folder

Page 6: Git & gitflow

Foobarsystem Co.,LTD

Local Operations

● Git directory● Working directory● Staging area

Page 7: Git & gitflow

Foobarsystem Co.,LTD

Remote Operations

Page 8: Git & gitflow

Foobarsystem Co.,LTD

Getting started

● Installing http://git-scm.com/● configuring git

$ git config --global user.name "John Doe"

$ git config --global user.email [email protected]

$ git config --global credential.helper cache

$ git config --global credential.helper "cache --timeout=3600"

$ git config --list

Page 9: Git & gitflow

Foobarsystem Co.,LTD

Basic linux commands

● pwd● ls -ah● cd● mv● rm● cp● touch

Page 10: Git & gitflow

Foobarsystem Co.,LTD

Initializing a Repository

➔ git status: show the current git repo status➔ git init: Initializing git repo

Add .git folder for repo setting

Page 11: Git & gitflow

Foobarsystem Co.,LTD

First commit

➔ touch readme : create a new readme file➔ edit readme : use favorite text editor➔ git status : show the current git repo status➔ git add : Adds file to track or submit changes

to commit➔ git commit -m “commit message” : commits

changes in added files➔ git rm <filename> : Delete a file

Page 12: Git & gitflow

Foobarsystem Co.,LTD

Commit history

git log : show commited log and information git log --since=2.weeksgit diff <file> : compare local change and current commit

Page 13: Git & gitflow

Foobarsystem Co.,LTD

Undoing Things

➔ git reset HEAD <file> : unstaging a staged file

➔ git checkout <file> : unmodify a modify file

Page 14: Git & gitflow

Foobarsystem Co.,LTD

Branching

git branch : show branches and current branchgit checkout -b <branchname> : create and checkout the new branch from current branchgit branch -d <branchname> : delete specified branch

Page 15: Git & gitflow

Foobarsystem Co.,LTD

Working with remote

➔ git remote add <shortname> <remote repo>➔ git remote : show current remote link➔ git remote -v : show shortname and url

remote respository➔ git push -u origin master

Page 16: Git & gitflow

Foobarsystem Co.,LTD

Pushing and fetching

➔ git push origin master : Pushed commits to origin remote

➔ git fetch origin : checks the latest in origin➔ git merge origin/master : merge

origin/master with local current branch➔ git pull : merge remote repository to current

local repository

Page 17: Git & gitflow

Foobarsystem Co.,LTD

Conflicts

● When merging modified file from remote with modified file in local repo

Page 18: Git & gitflow

Foobarsystem Co.,LTD

Git ignoring files$ cat .gitignore

# a comment - this is ignored# no .a files*.a# but do track lib.a, even though you're ignoring .a files above!lib.a# only ignore the root TODO file, not subdir/TODO/TODO# ignore all files in the build/ directorybuild/# ignore doc/notes.txt, but not doc/server/arch.txtdoc/*.txt# ignore all .txt files in the doc/ directorydoc/**/*.txt

Page 19: Git & gitflow

Foobarsystem Co.,LTD

Git Flow

Git Work Flow

Page 20: Git & gitflow

Foobarsystem Co.,LTD

Page 21: Git & gitflow

Foobarsystem Co.,LTD

Why gitflow?

● Based on the graph previous slide● Shortcuts for repetitive tasks● Branch naming convention

“<prefix>/<name>”● Fast to develop● 2 Main branches

Page 22: Git & gitflow

Foobarsystem Co.,LTD

Main branches

master : for productiondevelop : for ??

Suport branch● Feature branches● Release branches● Hotfix branches

Page 23: Git & gitflow

Foobarsystem Co.,LTD

Feature branches

May branch off from: developMust merge back into: developNaming convention: anything except master, develop, release-*, or hotfix-*