19
Git & Github workshop

Brainly git basics workshop

Embed Size (px)

DESCRIPTION

Slides from workshop about git basics

Citation preview

Page 1: Brainly git basics workshop

Git & Githubworkshop

Page 2: Brainly git basics workshop

AgendaGit basics- File status lifecycle- Staging and committing- Undoing thingsDistributed Git & Github I- Basic workflow (fork, commit, pull request)Branching- Creating and switching branches- Merging- RebasingDistributed Git & Github II- Distributed workflow- Synchronising with upstream and resolving conflicts

Page 3: Brainly git basics workshop

Git basics

$ git init

Page 4: Brainly git basics workshop

Git basics - file status lifecycle

$ git status

untracked unmodified modified staged

add the fileedit the file

stage the file

remove the file

commit

Page 5: Brainly git basics workshop

Git basics - staging and committing

Stage file and track untracked files$ git add <file name | wildcard>

Remove and stage file removal$ git rm <file name | wildcard>

Commit staged changes$ git commit -m “<message>”

Page 6: Brainly git basics workshop

Git basics - staging and commiting

$ cat .gitignoretmp/ # ignore all files in tmp dirlogs/*.log # all files in logs dir with .log*.tmp # all files with .tmp ext

Page 7: Brainly git basics workshop

Git basics - staging and commiting

Show unstaged changes$ git diff

Show staged changes$ git diff --cached

Page 8: Brainly git basics workshop

Git basics - staging and commiting

Show all commits with authors, dates and descriptions$ git log

Show all commits with complete diff$ git log -p

Show all commits with additions/deletions stats$ git log --stat

Page 9: Brainly git basics workshop

Git basics - undoing things

Change last commit$ git commit --amend

Unstage changes in given file$ git reset HEAD <file name>

Revert unstaged changes in given file$ git checkout -- <file name>

Page 10: Brainly git basics workshop

Git basics - distributed Git & Github I

blessed repository

Page 11: Brainly git basics workshop

Git basics - distributed Git & Github I

blessed repository

developerpublic

developerpublic

developerpublic

forkfork

fork

Page 12: Brainly git basics workshop

Git basics - distributed Git & Github I

blessed repository

developerpublic

developerpublic

developerpublic

developer private

developer private

developer private

clone clone clone

commit

Page 13: Brainly git basics workshop

Git basics - distributed Git & Github I

blessed repository

developerpublic

developerpublic

developerpublic

developer private

developer private

developer private

push

Page 14: Brainly git basics workshop

Git basics - distributed Git & Github I

blessed repository

developerpublic

developerpublic

developerpublic

developer private

developer private

developer private

pull request

Page 15: Brainly git basics workshop

Git basics - distributed Git & Github I

blessed repository

developerpublic

developerpublic

developerpublic

developer private

developer private

developer private

review pull request & merge

Page 16: Brainly git basics workshop

Git basics - distributed Git & Github I

$ git clone <url>$ git push <remote> <branch>

Page 17: Brainly git basics workshop

Git basics - Creating and switching branchesCreate branch$ git branch <name>

Activate branch$ git checkout <name>

Remove branch$ git branch -d <name>

Page 18: Brainly git basics workshop

Git basics - Creating and switching branchesMerge changes from branch <branch> to selected branch$ git merge <branch>

c0

b1 c1

c2b2

c3

branch commit

merge

Page 19: Brainly git basics workshop

Git basics - Creating and switching branchesRebase changes from branch <branch> to given branch$ git rebase <branch>

c0

b1 c1

c2b2

branch commit

c0

b1 c1

c2

b2

branch commit

c1

c2

rebase