An Intermediate Look at Git + GitHub U of T Scientific Coders - - PowerPoint PPT Presentation

an intermediate look at git github
SMART_READER_LITE
LIVE PREVIEW

An Intermediate Look at Git + GitHub U of T Scientific Coders - - PowerPoint PPT Presentation

An Intermediate Look at Git + GitHub U of T Scientific Coders University of Toronto October 1, 2015 fd7a4e4 : gh-pages Create 2015-10-08-Coworking4.markd... c3cb768 : Merge pull request #41 from mbonsma/gh-pages e2764b7 : Incorporated PR comments


slide-1
SLIDE 1

An Intermediate Look at Git + GitHub

U of T Scientific Coders

University of Toronto

October 1, 2015 fd7a4e4: gh-pages Create 2015-10-08-Coworking4.markd... c3cb768: Merge pull request #41 from mbonsma/gh-pages e2764b7: Incorporated PR comments into Biopython/less... d212bdd: Merge remote-tracking branch ‘upstream/gh-p... 85791b7: Added start and end time to event post b83b3e0: Merge remote-tracking branch ‘upstream/gh-p... 0b7d78c: Create 2015-10-01-MoreObGit.markdown

slide-2
SLIDE 2

Outline

1

Review

2

Viewing History

3

Branching

4

Collaborating with Others

1 / 13

slide-3
SLIDE 3

Section 1 Review

2 / 13

slide-4
SLIDE 4

Review

Configure your git client (git config user.name + user.email) Create a git repository (git init)

3 / 13

slide-5
SLIDE 5

Review

Configure your git client (git config user.name + user.email) Create a git repository (git init)

Working Directory

my_project/ .git/ foo/ bar/ baz.txt qux.txt ...

Repository Index/ Staging Area History

10 9 8 3 / 13

slide-6
SLIDE 6

Review

Configure your git client (git config user.name + user.email) Create a git repository (git init)

Working Directory

my_project/ .git/ foo/ bar/ baz.txt qux.txt ...

Repository Index/ Staging Area

(Snapshot) foo/ baz.txt ...

History

10 9 8

Start tracking a file with git (git add)

3 / 13

slide-7
SLIDE 7

Review

Configure your git client (git config user.name + user.email) Create a git repository (git init)

Working Directory

my_project/ .git/ foo/ bar/ baz.txt qux.txt ...

Repository Index/ Staging Area

(Snapshot) foo/ baz.txt ...

History

10 9 8

Start tracking a file with git (git add) Commit changes to the history (git commit)

3 / 13

slide-8
SLIDE 8

Review

Configure your git client (git config user.name + user.email) Create a git repository (git init)

Working Directory

my_project/ .git/ foo/ bar/ baz.txt qux.txt ...

Repository Index/ Staging Area

(Snapshot) foo/ baz.txt ...

History

10 9 8

Start tracking a file with git (git add) Commit changes to the history (git commit) Check what’s going on (git status) Compare a file with the one in the history (git diff) Look into your history (git log)

3 / 13

slide-9
SLIDE 9

Section 2 Viewing History

4 / 13

slide-10
SLIDE 10

Viewing History

Viewing the log allows you to “see” history: git log

5 / 13

slide-11
SLIDE 11

Viewing History

Viewing the log allows you to “see” history: git log git log <start>..<end> git log -- <file> git log --oneline git log --graph git log --graph --decorate

5 / 13

slide-12
SLIDE 12

Viewing History

Viewing the log allows you to “see” history: git log git log <start>..<end> git log -- <file> git log --oneline git log --graph git log --graph --decorate git blame <file>

5 / 13

slide-13
SLIDE 13

Viewing History

Viewing the log allows you to “see” history: git log git log <start>..<end> git log -- <file> git log --oneline git log --graph git log --graph --decorate git blame <file> gitk + gitg + other viewers

5 / 13

slide-14
SLIDE 14

Section 3 Branching

6 / 13

slide-15
SLIDE 15

Branches

What are branches? Divergent commits (two commits with the same parent) could be considered “virtual” branches

7 / 13

slide-16
SLIDE 16

Branches

What are branches? Divergent commits (two commits with the same parent) could be considered “virtual” branches Branches are simply a named pointer to a commit

7 / 13

slide-17
SLIDE 17

Branches

What are branches? Divergent commits (two commits with the same parent) could be considered “virtual” branches Branches are simply a named pointer to a commit Branches automatically move forward as commits are made

7 / 13

slide-18
SLIDE 18

Branches

What are branches? Divergent commits (two commits with the same parent) could be considered “virtual” branches Branches are simply a named pointer to a commit Branches automatically move forward as commits are made Why use them?

7 / 13

slide-19
SLIDE 19

Branches

What are branches? Divergent commits (two commits with the same parent) could be considered “virtual” branches Branches are simply a named pointer to a commit Branches automatically move forward as commits are made Why use them? They’re cheap! Just pointers. No heavy changes, e.g., an extra directory in svn.

7 / 13

slide-20
SLIDE 20

Branches

What are branches? Divergent commits (two commits with the same parent) could be considered “virtual” branches Branches are simply a named pointer to a commit Branches automatically move forward as commits are made Why use them? They’re cheap! Just pointers. No heavy changes, e.g., an extra directory in svn. To keep experimental work apart

7 / 13

slide-21
SLIDE 21

Branches

What are branches? Divergent commits (two commits with the same parent) could be considered “virtual” branches Branches are simply a named pointer to a commit Branches automatically move forward as commits are made Why use them? They’re cheap! Just pointers. No heavy changes, e.g., an extra directory in svn. To keep experimental work apart To separate trials

7 / 13

slide-22
SLIDE 22

Branches

What are branches? Divergent commits (two commits with the same parent) could be considered “virtual” branches Branches are simply a named pointer to a commit Branches automatically move forward as commits are made Why use them? They’re cheap! Just pointers. No heavy changes, e.g., an extra directory in svn. To keep experimental work apart To separate trials To ease collaboration

7 / 13

slide-23
SLIDE 23

Branches

Managing branches: git branch <name> [commit] git branch -d <name> git branch [-l]

8 / 13

slide-24
SLIDE 24

Branches

Managing branches: git branch <name> [commit] git branch -d <name> git branch [-l] Switching branches: git checkout <branch name> git checkout -b <branch name> [commit] — Create and switch in one go

8 / 13

slide-25
SLIDE 25

Branches

Managing branches: git branch <name> [commit] git branch -d <name> git branch [-l] Switching branches: git checkout <branch name> git checkout -b <branch name> [commit] — Create and switch in one go Merging branches: git merge <other branch name> git merge --ff-only <other branch name> git merge --no-ff <other branch name>

8 / 13

slide-26
SLIDE 26

Section 4 Collaborating with Others

9 / 13

slide-27
SLIDE 27

Clones and Remotes

Clones are complete copies of a repository’s history (i.e., excluding the index and working directory)

10 / 13

slide-28
SLIDE 28

Clones and Remotes

Clones are complete copies of a repository’s history (i.e., excluding the index and working directory) git clone <URI>

10 / 13

slide-29
SLIDE 29

Clones and Remotes

Clones are complete copies of a repository’s history (i.e., excluding the index and working directory) git clone <URI> Remotes are pointers to other clones

10 / 13

slide-30
SLIDE 30

Clones and Remotes

Clones are complete copies of a repository’s history (i.e., excluding the index and working directory) git clone <URI> Remotes are pointers to other clones git remote [-v] git remote add <name> <URI> git remote rm <name> Local branches can track remote branches git branch -u <remote branch> <local branch>

10 / 13

slide-31
SLIDE 31

Clones and Remotes

Clones are complete copies of a repository’s history (i.e., excluding the index and working directory) git clone <URI> Remotes are pointers to other clones git remote [-v] git remote add <name> <URI> git remote rm <name> Local branches can track remote branches git branch -u <remote branch> <local branch> You are responsible for syncing git push [<remote>] [<branch>] git fetch [<remote>] git pull [<remote>] — fetch + merge

10 / 13

slide-32
SLIDE 32

GitHub Example

slide-33
SLIDE 33

Section 5 Advanced Topics

12 / 13

slide-34
SLIDE 34

Advanced Topics

git add --patch

13 / 13

slide-35
SLIDE 35

Advanced Topics

git add --patch git rebase

13 / 13