I
Contains the snapshots to be used in creating the next commit
Consequences
I
Commits can be built thematically
I
Commits can be relatively small, even if changes to be committed are
large (useful for
git bisect
)
(University of Michigan)
Lab 4: VCS
Friday, October 2
nd
, 2015
36 / 63

Git
Git Basics by Example
Git Commands:
commit
What does
git commit
do?
I
Combines everything in the staging area into a commit, described by
your log message
I
Adds it all to the local repo
I
Points at it with a
commit hash
I
Changes
HEAD
to point at that commit hash
Syntax and Options
I
Example:
git commit
I
Interesting things are possible with
commit hooks
(University of Michigan)
Lab 4: VCS
Friday, October 2
nd
, 2015
37 / 63

Git
Git Basics by Example
Git Ettiquette: Commits
What is a good commit?
I
Informative message – short one liner followed by thorough paragraphs
describing all of the changes
I
Thematic – all of the changes should go together logically (e.g. added
a module and integrated it)
I
Small – keeping your changes small makes it easier to find what broke
everything by binary searching the commit history (
bisect
)
Why?
I
All of these rules make it easier to find bugs and understand the
progression of a project
I
Most are mandatory at companies
(University of Michigan)
Lab 4: VCS
Friday, October 2
nd
, 2015
38 / 63

Git
Git Basics by Example
Git Diagram
Git Repo Structure
[origin]
HEAD=9a12490
Mark
HEAD=9a12490
Jon
HEAD=f2ea0f5
Will
HEAD=9a12490
Commit Tree
9a12490
f2ea0f5
(University of Michigan)
Lab 4: VCS
Friday, October 2
nd
, 2015
39 / 63

Git
Git Basics by Example
Git Commands by Example:
commit
[[email protected] slides] [master +] $ git commit
[master f2ea0f5] Lab 4 diagram change
1 file changed, 1 insertion(+), 1 deletion(-)
(University of Michigan)
Lab 4: VCS
Friday, October 2
nd
, 2015
40 / 63

Git
Git Basics by Example
Git Commands:
push
What does
git push
do?
I
Puts all of your local commits on some remote
Syntax and Options
I
Example:
git push
I
Defaults to pushing the
master
branch to the
origin
repo
I
Interesting things are possible with
push hooks
(University of Michigan)
Lab 4: VCS
Friday, October 2
nd
, 2015
41 / 63

Git
Git Basics by Example
Git Diagram
Git Repo Structure
[origin]
HEAD=f2ea0f5
Mark
HEAD=9a12490
Jon
HEAD=f2ea0f5
Will
HEAD=9a12490
Commit Tree
9a12490
f2ea0f5
(University of Michigan)
Lab 4: VCS
Friday, October 2
nd
, 2015
42 / 63

Git
Git Basics by Example
Git Commands by Example:
push
[[email protected] slides] [master] $ git push
Counting objects: 11, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 475 bytes | 0 bytes/s, done.
Total 6 (delta 3), reused 0 (delta 0)
To [email protected]:eecs470staff/course_material.git
9a12490..f2ea0f5
master -> master
(University of Michigan)
Lab 4: VCS
Friday, October 2
nd
, 2015
43 / 63

Git
Git Basics by Example
Git Commands:
pull
What does
git pull
do?
I
Gets all commits from some remote
I
This is actually a combination of
git fetch
followed by
git merge
Syntax and Options
I
Example:
git pull
I
Defaults to pulling the
master
branch from the
origin
repo
(University of Michigan)
Lab 4: VCS
Friday, October 2
nd
, 2015
44 / 63

Git
Git Basics by Example
Git Diagram
Git Repo Structure
[origin]
HEAD=f2ea0f5
Mark
HEAD=f2ea0f5
Jon
HEAD=f2ea0f5
Will

