Lesson 0.5 Introduction To Git
Lesson 0.5 Introduction To Git
2
Git is a distributed version-control system
4
A simple model of git
• Most git documentation gets into details very
quickly.
• Here’s a very simple model of what’s going on
in git.
5
Your files
my-project docs manual.docx
user_docs.docx
src
main.rkt
module1.rkt
module2.rkt
module3.rkt
6
Your files in your git repository
.git
user_docs.docx
src
main.rkt
When you have a git repository, you have an
module1.rkt
additional directory called .git, which points
module2.rkt
at a mini-filesystem.
module3.rkt
7
The git client
.git
user_docs.docx
src
main.rkt
This mini-filesystem is highly optimized and
module1.rkt
very complicated. Don’t try to read it
module2.rkt
directly.
module3.rkt
8
Your workflow (part 1)
• You edit your local files directly.
– You can edit, add files, delete files, etc., using
whatever tools you like.
– This doesn’t change the mini-filesystem, so now
your mini-fs is behind.
9
A Commit
.git
user_docs.docx
src
When you do a “commit”, you
main.rkt
record all your local changes into
the mini-fs.
module1.rkt
module2.rkt
commit
module3.rkt
The mini-fs is “append-only”.
Nothing is ever over-written
there, so everything you ever
commit can be recovered.
10
Synchronizing with the server (1)
a server, somewhere on the
your local machine
internet, eg. github.com
.git push
manual.doc
my-project docs x
user_docs.d
ocx
src
main.rkt
module1.rk
t
module2.rkt
.git pull
manual.doc
my-project docs x
user_docs.d
ocx
src
main.rkt
pull
module1.rk
t
module2.rkt
module2.rkt
module3.rkt
commit
13
The whole picture using GHFW
a server, somewhere on the
your local machine
internet, eg. github.ccs.neu.edu
.git sync
manual.doc
my-project docs x
user_docs.d
ocx
src
main.rkt
sync
module1.rk
t
module2.rkt
module3.rkt
In Gihub For Windows or Github For Mac,
“push” and “pull” are combined into a
commit single operation called “sync”. So in these
clients, there are only two steps (“commit”
and “sync”) to worry about, not three.
14
Your workflow (2)
sync
sync
15
Using Github for Windows/Mac
16
Your workflow with a partner
Your Partner (or
you on another
You computer) You
19
Where am I?
• The open blue circle indicates that you are looking at the most
recent local files
20
Always start by syncing
• This will download any changes that you or your partner have
made on other machines
21
Click on a dot to see a commit
• Clicking on the last dot will show you what was in your last
commit
• The dot turns blue
22
This shows your commit SHA
• In this view, you can see the first 6 characters of the unique
identifier (“the SHA”) for this commit
• You’ll need it for your Worksession Report
23
Now let’s work on our file
• Now the screen shows an uncommitted change.
24
Next, we commit our work
• We write a commit message. Then we’ll click on “Commit to
Master”
25
Here’s what you’ll see after a commit
• Now it says “No uncommitted changes” again.
• You can also undo the commit if you want.
26
Be sure to record the commit SHA
• Click on the open circle to see what was in your commit, and
to record the commit SHA. Here’s that screen again:
27
Be sure to sync!!!
• Your work is not saved on the server until you sync.
28
Submit a Work Session Report
• At the end of your work
session, submit a work
session report via the web.
• The URL for the work
session report will appear in
each problem set.
• The report will ask for the
SHA of your last commit.
You can get this from the
Github Desktop, as we’ve
shown you.
29
Summary
• In this lesson you have learned
– that git creates a mini-filesystem in your directory
– what commit, push, pull, and sync do
– the elements of the basic git workflow
– how git allows you to work across multiple
computers
– how git allows you and a partner to work together
30