Git Primer

Post on 27-Oct-2014

655 views 0 download

Tags:

description

Uploaded from Google Docs

Transcript of Git Primer

Git > SVN ..and most other

VCS

whygitisbetterthanx?

awesome branching!

the staging area

it's local!

fast, small, distributed...

http://thkoch2001.github.com/whygitisbetter/

http://whygitisbetterthanx.com

setup...

git config --global user.name "Keith Mascarenhas"

git config --global user.email "keith.mascarenhas@efinlab.com"

git config --global color.ui true

lets begin!

cd app

git init

local staging..

Make changes to app..

git status OR git diff

git add .

git commit -m 'made xyz change'

useful git add shortcuts..

git add . [stages modified and deleted, without new]

git add -u [stages new and modified, without deleted]

git add -A [stages All]

branching! ^^

git branch <new_branch_name> [creates branch]

git checkout <branch_name> [switch current working

directory to this branch]

'master' is our default root branch.

branching! ^^

git checkout master

+

git branch issue53

+

git checkout issue53

=

git checkout -b issue53 master

git checkout -b [new branch name] [source branch name]

merging! ^^

git checkout master

git merge issue53

deleting branches..

git branch -d <branch_name> [Recommended]

lets work remote!

setting up unfuddle

cd ../app/

git init

git remote add unfuddle git@efl.unfuddle.com:efl/app-dev.git

git config remote.unfuddle.push refs/heads/master:refs/heads/master

or just migrate our svn repo!

git svn clone [svn_repo_url] /path/to/git/repo

cd /path/to/git/repo

git remote add origin git@efl.unfuddle.com:efl/app-dev.git

git push origin master

now clone it! [svn checkout]

git clone git@efl.unfuddle.com:efl/app-dev.git

[svn commit]

Make changes in xyz..

git commit -am "changed xyz"

git push <-> [svn commit]

git push origin master

git push [remote_name] [branchname_you_want_to_commit]

[svn update]

git fetch

+

git merge origin/master

=

git pull

git pull origin/master <-> [svn update]

git pull origin [branch_name]

push a branch to remote!

git checkout -b issue53 branch_x

git commit

git push origin issue53

Someone else..

git fetch

tagging..

git tag -a v1.0

git tag [list them]

git tag -l 'v1.4.2.*' v1.4.2.1

v1.4.2.2

v1.4.2.3

v1.4.2.4

git show v1.0

git push origin --tags

misc..

git log [--oneline] [--graph] [--all] [--stat]

git config --global alias.lolz "log --oneline --graph -all"

git lolz --decorate

git config --global alias.co "checkout"

git log issue53 ^master [incoming: origin/master ^master]

git log issue52 ^issue53 [outgoing: master ^origin/master]

git roundup!

git config

git init

git clone

git status

git add

git commit

git branch

git checkout

git merge

git push

git fetch

git merge

our workflow

thanks to Vincent Driessen (http://nvie.com/posts/a-successful-git-branching-model/)

(app-prod)(app-stg)(app-dev)

app85

app85.0.1

app87

(app-prod)(app-stg)(app-dev)

app85

app85.0.1

app87

don't freak out!

(app-prod)(app-stg)(app-dev)

app85

app85.0.1

app87

(app-prod)(app-stg)(app-dev)

app85

app85.0.1

app87

(app-dev)(app-dev) (app-prod)

main branches

app85

app87

app89

feature branches

Creating a feature branch

When starting work on a new feature, branch off from the develop branch.$ git checkout -b myfeature developSwitched to a new branch "myfeature"

Incorporating a finished feature on develop

Finished features may be merged into the develop branch definitely add them to the upcoming release:$ git checkout developSwitched to branch 'develop'$ git merge --no-ff myfeatureUpdating ea1b82a..05e9557(Summary of changes)$ git branch -d myfeatureDeleted branch myfeature (was 05e9557).$ git push origin develop

feature:branch off develop

merge back into develop

name: anything except: master, develop, hotfix-*, release-*

(app-dev) (app-prod)

--no-ff?

app85

app87

release & hotfix branches

(app-prod)(app-stg)(app-dev)

app85

app85.0.1

app87

release:branch off develop

merge back into develop & master

name: release-*

hotfix:

branch off master

merge back into develop & master

name: hotfix-*

(app-prod)(app-stg)(app-dev)

app85

app85.0.1

app87

thats it!

you dont need to rtfd but it helps..

gitref.org

git-scm.com/docs

Introduction to Git - Scott Chacon

bit.ly/introtogit

bit.ly/introtogitdeck

Branching Model

bit.ly/branchingmodel

This awesome deck!

http://bit.ly/thisdeck