git

47

Upload: omar-al-sabek

Post on 13-Apr-2017

140 views

Category:

Education


1 download

TRANSCRIPT

Page 1: Git
Page 2: Git
Page 3: Git
Page 4: Git
Page 5: Git
Page 6: Git
Page 7: Git
Page 8: Git
Page 9: Git
Page 10: Git

without git

feature 1 feature 2 feature 3 feature 4 feature 5

final

Page 11: Git

project-v1

project

without git

project-v2 project-v3 project-final

Page 12: Git

without git

?

Page 13: Git
Page 14: Git
Page 15: Git

setting up git

Page 16: Git

the basics

Page 17: Git

Typical workflow

Person A

• Setup project

• push code onto github

• edit/commit

• edit/commit

• pull/push

Person B

• clone code from github

• edit/commit/push

• edit…

• edit… commit

• pull/push

Page 18: Git
Page 19: Git

parts of a git repository

working directory

staging area (index)

git directory(HEAD)

stage commit

checkout

Page 20: Git
Page 21: Git
Page 22: Git

getting a git repository

git init

create one

git clone /path/to/repository

copy an existing repository

timeline

HEADmaster

timeline

HEADmaster

Page 23: Git

checking project status

git status file status

untracked

unmodified

modified

staged

Page 24: Git

tracking files / staging files

git add [filename]

git add [filename1] [filename2] [filename3]

git add . or git add *

untracked staged

modified staged

Page 25: Git

committing changes

git commit

git commit –m “commit message”

staged unmodified

timeline

HEADmaster

Page 26: Git

git work flow

create / delete / modify files

stage files

commit changes

[repeat]

git commit –am “commit message”

Page 27: Git

removing files

git rm [filename]

git rm [filename1] [filename2] [filename3]

removes the file from the staging area and the working directory

Page 28: Git

untracking files

git rm --cached [filename]

staged untracked

Page 29: Git

undoing things

git checkout -- [filename]

discarding changes

modified unmodified

git reset HEAD [filename]

unstaging files

git reset HEAD

staged modified

Page 30: Git

undoing things

git commit --amend

changing the last commit

git reset --soft HEAD

undoing the last commit

unmodified staged

git reset --hard HEAD discard all changes in last commit

Page 31: Git

viewing changes

git diff

unstaged changes

git show [commit hash]

changes done in a commit

git diff --cached

staged changes

Page 32: Git

viewing commit history

git log

git log --oneline

git log --graph

git log --since=“2013-12-01”

git log --author=“Lorem Ipsum”

git log --until=“2013-12-01”

Page 33: Git

branching

Page 34: Git

branching

timeline

HEAD

feature

master

git branch

list all branches

Page 35: Git

creating a branch

git branch [branch name] git checkout [branch-name]

switch to the new branch

timeline

HEAD

[branch name]

master timeline

HEAD

[branch name]

master

git checkout –b [branch name]

Page 36: Git

committing to branches

timeline

master

HEAD

feature

git commit –m “commit message”

Page 37: Git

merging branches

git checkout [branch to merge into]

switch to the branch you want to merge into

git merge [branch to merge from]

perform merge

Page 38: Git

deleting a branch

git checkout [some other branch]

switch to a branch other than the one to be deleted

git branch –d [branch name]

delete branch

Page 39: Git

collaboration

Page 40: Git

setting up for Github

sign up for a Github account

generate SSH key (if your machine currently doesn’t have one)

add your SSH key to your Github account

Page 41: Git

two repositories

local repository- working directory- staging area- git directory

remote repository

- git directory

Page 42: Git

remotes

git remote

showing all remotes

git remote -v

include remote URL

Page 43: Git

managing remotes

git remote add [remote name] [remote URL]

creating a new remote

git remote rm [remote name]

deleting a remote

Page 44: Git

data transfer to/from a remote

git push [remote name] [remote branch name]

sending data to a remote

git pull [remote name] [remote branch name]

getting data from a remote

Page 45: Git

collaboration

Page 46: Git
Page 47: Git

Thanks For Listening