Upload
lukasz-lalik
View
263
Download
2
Embed Size (px)
DESCRIPTION
Slides from workshop about git basics
Citation preview
Git & Githubworkshop
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
Git basics
$ git init
Git basics - file status lifecycle
$ git status
untracked unmodified modified staged
add the fileedit the file
stage the file
remove the file
commit
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>”
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
Git basics - staging and commiting
Show unstaged changes$ git diff
Show staged changes$ git diff --cached
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
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>
Git basics - distributed Git & Github I
blessed repository
Git basics - distributed Git & Github I
blessed repository
developerpublic
developerpublic
developerpublic
forkfork
fork
Git basics - distributed Git & Github I
blessed repository
developerpublic
developerpublic
developerpublic
developer private
developer private
developer private
clone clone clone
commit
Git basics - distributed Git & Github I
blessed repository
developerpublic
developerpublic
developerpublic
developer private
developer private
developer private
push
Git basics - distributed Git & Github I
blessed repository
developerpublic
developerpublic
developerpublic
developer private
developer private
developer private
pull request
Git basics - distributed Git & Github I
blessed repository
developerpublic
developerpublic
developerpublic
developer private
developer private
developer private
review pull request & merge
Git basics - distributed Git & Github I
$ git clone <url>$ git push <remote> <branch>
Git basics - Creating and switching branchesCreate branch$ git branch <name>
Activate branch$ git checkout <name>
Remove branch$ git branch -d <name>
Git basics - Creating and switching branchesMerge changes from branch <branch> to selected branch$ git merge <branch>
c0
b1 c1
c2b2
c3
branch commit
merge
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