SlideShare a Scribd company logo
1 of 112
Download to read offline
an introduction to
git
(even for non-developers)
john sj anderson · @genehack · os101/columbia • 17 apr 2018
1 — intro to git — os101/columbia — @genehack
vp of tech, infinity interactive
custom software development
and technology consulting
hi, i’m john.
also known as
@genehack
2 — intro to git — os101/columbia — @genehack
do you identify as a non-developer?
developer? something in between?
no experience with git? some
experience? consider yourself a git
expert?
for those w/git experience, how
many of you are anxious about git?
let’s start out with
an audience
survey3 — intro to git — os101/columbia — @genehack
simplify and de-mystify git
open source desperately needs non-
developer contributions, but git anxiety
can block or slow down otherwise
helpful contributions. i'd like to help
people understand git a little bit better,
to work to reduce that barrier to entry
my goals for this
talk4 — intro to git — os101/columbia — @genehack
going to talk about how you get a git
repository to work on
adding and changing files
sending changes back up to the original
branching and merging
saving your bacon when things go pear-
shaped
additional resources
talkoverview5 — intro to git — os101/columbia — @genehack
this is a tough topic. there's lots of
jargon
i'm going to try to explain things in
different terms than are normally used to
ease that a bit.
trying really hard to avoid saying "just",
"simple", "easy", etc. please help me
here.
ground
rules6 — intro to git — os101/columbia — @genehack
what is
git?7 — intro to git — os101/columbia — @genehack
this definition has the unique
combination of being 100% accurate
and also being completely useless
unless you already know what it means.
so if you don't already know what it
means, you will be forgiven if your
reaction to this definition is ...
distributed
revision
control
system
8 — intro to git — os101/columbia — @genehack
9
wat.
10
let's break this down into a
couple of parts. first, let's
consider 'revision control
system'.
what's a revision control
system?
distributed
revision
control
system
11 — intro to git — os101/columbia — @genehack
12 — intro to git — os101/columbia — @genehack
revision control systems
(rcs, cvs, svn, tfs, git, etc)
are a fundamental
building block of software development.
13 — intro to git — os101/columbia — @genehack
<insert rant about how this
stuff should be taught in
school>
a brief
aside14 — intro to git — os101/columbia — @genehack
ok, so that's 'revision control
system' -- what about the
'distributed' part? what's that
mean?
distributed
revision
control
system
15 — intro to git — os101/columbia — @genehack
16 — intro to git — os101/columbia — @genehack
another
brief aside
17 — intro to git — os101/columbia — @genehack
git is a really nice fit for any kind of text-
based stuff that changes over time --
websites, recipes, writing, your resume,
etc.
git will even work okay with binary
formats, it's just a bit harder to see
some of the changes that happen that
way.
git’s not only for
code.18 — intro to git — os101/columbia — @genehack
git is also not
github.19 — intro to git — os101/columbia — @genehack
also not bitbucker, not team
foundation server
all of these are sites that provide
hosting for git-based projects
along with a number of other
project management tools.
git is also not
gitlab.20 — intro to git — os101/columbia — @genehack
they're way bigger than the scope of
this talk, and the material in this talk
applies equally to any of them. i
encourage you to initially focus on
learning the basics of git, and only
then start to focus on the git hosting
site you (or the project you've chosen
to work on) have decided to use.
learning the basics
of git will help you
regardless of what git hosting is used
21 — intro to git — os101/columbia — @genehack
so, one of the initial things you
need to do, if you don't already
have git installed, is to get git.
getting
git22 — intro to git — os101/columbia — @genehack
you can do this by going to git-
scm.com...
note that i will put these slides up
for download after the talk, and
tweet out the location, so you
don't need to worry about writing
down each url...
git-scm.com
where they will have links to install it for
whatever platform you're on.
if you're running something with a
package manager (linux, mac with brew,
etc.) just using the package manager
may be easier.
you may also see that they have links
here to 'Mac GUIs'...
...so this is a good time to talk about GUI git versus CLI git.
after thinking about this for a bit, i decided to give all the
examples in this talk in terms of the CLI. that was for a few
reasons:
when you need to do a net search for help with something,
most of the results will be given in terms of the CLI, so having
a basic understanding will help
showing a GUI in addition to the CLI examples would
effectively halve the amount of stuff i can get through (and the
talk is already groaning when jammed into a 30 minute slot)
there are a bunch of Git GUIs and this way i didn't have to pick
just one to show
cli
versus
gui25 — intro to git — os101/columbia — @genehack
aside: if you're not familiar with the CLI,
it's a useful skill to have as an open
source contributor, even as a non-
developer. Tracy Osborn, who has
done some nice intro web design and
web programming books, just recently
released a free e-book called "really
friendly command line intro"
26
you can grab a copy here --
and again, slides available
online later, so you don't have
to copy this down.
hellowebbooks.com/learn-command-line
27
before we do anything else,
we need to tell git
who we are
28 — intro to git — os101/columbia — @genehack
git config is a git command for modifying
configuration values. in this case, we're giving it the --
global flag to indicate that we want to modify the
configuration for any use of git. and then we set the
user.name and user.email values to our name and email.
this information is needed because once we start
making changes (here in a few slides), git is going to
track who made what change. if you don't provide these
values for it, sometimes git will try to guess, and it will
probably get it wrong. (and when it doesn't guess, it will
just refuse to work until you run the above commands.)
git config --global user.name "Put your name here"
git config --global user.email "email@example.com"
29 — intro to git — os101/columbia — @genehack
now that we've got the
required git configuration
done, we need to get a
repository to work on.
step one: obtaining a
repository
30 — intro to git — os101/columbia — @genehack
oh, wait, there's some jargon. what's a
"repository"?
a repository is just what git calls a
project, or a directory where the
contents are under the control of git
you'll also hear people say "repo"
because "repository" is an annoyingly
long word to have to type out a bunch
jargon:
repository31 — intro to git — os101/columbia — @genehack
'clone' is what git calls making a copy
of somebody else's existing repository.
this is typically what you'll do if you
want to contribute to an open source
project -- you'll make a clone of the
project's repo so that you can look at
what's there, and possibly change it
and contribute it back to the project.
first option:
clone32 — intro to git — os101/columbia — @genehack
this is the github page for an
open source project -- one
that happen's to be one of
mine, a perl module for
interacting with git. if you click
this green button here...
...you'll get a little popup with a
URL you can copy...
...and in fact this little circled
button here does just that,
copies the URL to the
clipboard for you.
then you can open up a
terminal and run the following
command to clone the
repository
git clone <url>
36 — intro to git — os101/columbia — @genehack
and here's the output you'll see
when you do. this first line tells you
it's cloning into a directory named
'Git-Wrapper' in the current
working directory, and the other
lines here are just stats about the
size of the repository, basically.
$ git clone https://github.com/genehack/Git-Wrapper.git
Cloning into 'Git-Wrapper'...
remote: Counting objects: 4067, done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 4067 (delta 16), reused 33 (delta 16), pack-reused 4028
Receiving objects: 100% (4067/4067), 3.20 MiB | 5.80 MiB/s, done.
Resolving deltas: 100% (1917/1917), done.
37 — intro to git — os101/columbia — @genehack
the other option for getting a
repository is to create a fresh,
new empty one
second option:
diy38 — intro to git — os101/columbia — @genehack
you do that with the 'git init'
command. it will create a new
repo in a directory named for
the project
git init <project-name>
39 — intro to git — os101/columbia — @genehack
so, as you can see here, when we run the
command, it creates the directory for us
the directory contains only .git
.git contains a bunch of stuff
you can ignore all of this for the moment, but you
need to understand that the .git directory is where
git stores all the data about the repository itself. if
you remove the .git directory, you turn the repo
into just an ordinary directory containing files.
$ git init my-new-project
Initialized empty Git repository in /Users/genehack/my-new-project/.git/
$ ls -a my-new-project
./ ../ .git/
$ ls -a my-new-project/.git
./ ../ HEAD branches/ config description hooks/ info/ objects/ refs/
40 — intro to git — os101/columbia — @genehack
ok, now we have a repo! yay!
ok, now we have a
repo41 — intro to git — os101/columbia — @genehack
let's keep working with the fresh new empty repo.
the first thing we need to do is add a file to it.
let's add a README file with some basic info about
the project
README files are traditionally found in the top level
of a repository and contain basic introductory
material about the project -- what problems it aims
to solve, how to use it, maybe instructions on how
to contribute back to the project, etc.
so let's make that file...
let’s
add a file
to it42 — intro to git — os101/columbia — @genehack
yes, yes, i'm an emacs user.
so, let's pretend we write some
basic stuff in the README.md and
save it
photo credit: https://
www.flickr.com/photos/rore/
4457009838 (cc/by/2.0)
emacs README.md
43 — intro to git — os101/columbia — @genehack
we need to ask git what's
going on with the repository.
the way we do that ...
next, we need to ask git
“sup?”44 — intro to git — os101/columbia — @genehack
...is with a command called
git status
git status
45 — intro to git — os101/columbia — @genehack
when we run git status, we see that
git is telling us, "hey, there's this file here,
but you haven't told me to track it or
anything -- just letting you know, i see it"
git also helpfully tells you, "hey, if you
want me to be be tracking it, you need to
git add it"...
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
README.md
nothing added to commit but untracked files present (use "git add" to track)
46 — intro to git — os101/columbia — @genehack
so let's run that command
next, git add
git add README.md
47 — intro to git — os101/columbia — @genehack
and then check the status
again
git status
48 — intro to git — os101/columbia — @genehack
and now we can see git is
telling us, "yo, got a new file
here!"
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: README.md
49 — intro to git — os101/columbia — @genehack
if you look at the
documentation for git add,
you'll see something like this:
<read slide>
git add
stages
changes to be committed
50 — intro to git — os101/columbia — @genehack
there's another piece of jargon
to break down -- "staging
area" "
jargon:
staging area51 — intro to git — os101/columbia — @genehack
you can even see here, in the
git status output, git is
telling us how to "unstage"
something
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: README.md
52 — intro to git — os101/columbia — @genehack
to get this jargon, you need to
understand the different states
git thinks files can be in, or the
lifecycle that a file moves
through
the lifecycle of file changes
according to git
53 — intro to git — os101/columbia — @genehack
as we saw, when we create a
new file, it ends up in a state
called "untracked".
untracked
staged
committed54 — intro to git — os101/columbia — @genehack
and git add is what takes us out of that
"untracked" state, and puts us into "staged".
"staged" is an area in between 'untracked'
and 'committed', which allows you to build
up what's going to be in a commit piece by
piece. this isn't something you'll care too
much about when you're just getting
started.
‘git add’ takes you
from “untracked” to
“staged”55 — intro to git — os101/columbia — @genehack
so how do we go
from “staged” to
“committed”?
56 — intro to git — os101/columbia — @genehack
git commit
57 — intro to git — os101/columbia — @genehack
the commit message is going to
describe what's in the commit, and
possibly why the change is being made
this is the part where your name and
email address -- the stuff we fed into
git config way back when --
comes into play
git wants commits to
have an accompanying
commit message
58 — intro to git — os101/columbia — @genehack
by default, cli git uses
vimto write commit messages
59 — intro to git — os101/columbia — @genehack
https://twitter.com/
thepracticaldev/status/
747871086478516226?
lang=en
if you’re not already
a vim userthis is probably not what you want.
60 — intro to git — os101/columbia — @genehack
instead you can use the -m
flag and give the commit
message as part of the
command
git commit -m "<your message here>"
61 — intro to git — os101/columbia — @genehack
to review, git add...
git add takes files
from “untracked”
to “staged”
62 — intro to git — os101/columbia — @genehack
...and git commit
git commit takes files
from “staged”
to “committed”
63 — intro to git — os101/columbia — @genehack
so that covers adding a file to
the repo. what if we need to
revise it?
so, what about
edits?64 — intro to git — os101/columbia — @genehack
pretend we edit the file again,
and ...
emacs README.md
65 — intro to git — os101/columbia — @genehack
we ask git, "sup?"
git status
66 — intro to git — os101/columbia — @genehack
and we see something new!
git tells us the file has been
modified
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: README.md
no changes added to commit (use "git add" and/or "git commit -a")
67 — intro to git — os101/columbia — @genehack
so let's return to our lifecycle...
the lifecycle of file changes
according to git
68 — intro to git — os101/columbia — @genehack
...and we need to add a fourth
state, modified. so we have
untracked, staged, committed,
and modified.
untracked
staged
committed
modified
69 — intro to git — os101/columbia — @genehack
you might wonder, since git
knows the file is changed, can
it tell you how it was changed?
can we ask git
“yo, what changed?”
70 — intro to git — os101/columbia — @genehack
and yes, it can, with a
command called 'git diff'.
git diff
71 — intro to git — os101/columbia — @genehack
<briefly walk through diff>
$ git diff
diff --git a/README.md b/README.md
index bf3d7ca..9a71af8 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,3 @@
# My Awesome New Project
+
+**FIXME:** write README
72 — intro to git — os101/columbia — @genehack
at this point, to get the changes to
README.md committed, you're
going to do the exact same steps as
with adding the file for the first time:
you're going to use 'git add' to stage
the change, and then you're going
to use 'git commit' to commit it.
adding and editing files is
notvery different73 — intro to git — os101/columbia — @genehack
first we stage the changes
git add README.md
74 — intro to git — os101/columbia — @genehack
and then we commit them
git commit -m "<explain the change>"
75 — intro to git — os101/columbia — @genehack
git records the commit messages and then
lets you look back at them. this is called the
'history' of the repository.
when you're first getting involved with a new
open source project, taking some time to read
over the recent history of the repo is a great
way to get up to speed -- you'll see which
files have changed recently, and see who's
actually doing the work to put in the changes
so, what's going on with those
commit
messages?76 — intro to git — os101/columbia — @genehack
the way you look at the history
is with a command called git
log. running it ends up
looking like this:
git log
77 — intro to git — os101/columbia — @genehack
$ git log
commit f2645941f26ab276bed99b12f170e97ca9c90106
Author: John SJ Anderson <john@genehack.org>
Date: Sat Apr 14 17:04:36 2018 -0400
Update README with FIXME
commit 3e805602660713b8f98f610cf178df70c2ceb91f
Author: John SJ Anderson <john@genehack.org>
Date: Sun Apr 15 07:00:14 2018 -0400
Add README.md
78 — intro to git — os101/columbia — @genehack
you can also include the -p
flag -- for patch -- to ask git
to show you the exact lines
that were changed in each
commit. that looks like...
git log -p
79 — intro to git — os101/columbia — @genehack
$ git log -p
commit f2645941f26ab276bed99b12f170e97ca9c90106
Author: John SJ Anderson <john@genehack.org>
Date: Sat Apr 14 17:04:36 2018 -0400
Update README with FIXME
diff --git a/README.md b/README.md
index bf3d7ca..9a71af8 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,3 @@
# My Awesome New Project
+
+**FIXME:** write README
80 — intro to git — os101/columbia — @genehack
commit 3e805602660713b8f98f610cf178df70c2ceb91f
Author: John SJ Anderson <john@genehack.org>
Date: Sun Apr 15 07:00:14 2018 -0400
Add README.md
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..bf3d7ca
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+# My Awesome New Project
81 — intro to git — os101/columbia — @genehack
a few more
concepts
82 — intro to git — os101/columbia — @genehack
branches
83 — intro to git — os101/columbia — @genehack
a branch is
a new working copy
of your repo
84 — intro to git — os101/columbia — @genehack
branches allow you to make
changes
without altering the underlying
master copy85 — intro to git — os101/columbia — @genehack
when the work on the branch passes review,
you need to
merge86 — intro to git — os101/columbia — @genehack
pushing
87 — intro to git — os101/columbia — @genehack
pushing means
sending changes
to some other copy
of the repository
88 — intro to git — os101/columbia — @genehack
the repository you're
pushing changes to is called a
remote89 — intro to git — os101/columbia — @genehack
pull request
90 — intro to git — os101/columbia — @genehack
a request to merge
your changes into
their repository
91 — intro to git — os101/columbia — @genehack
what to do when things go
bad
92 — intro to git — os101/columbia — @genehack
two fixes that
(almost) always
work93 — intro to git — os101/columbia — @genehack
the first approach is good when you've
got things into a bad state and you
think you know the fix but are worried
that you're going to mess things up
worse: make a copy, try the fix on the
copy, and then if it works, do it to actual
directory. (and if it fails, throw away the
copy and try something else!)
one:
make a copy of your repo
& try a fix
on the copy
94 — intro to git — os101/columbia — @genehack
if you have modified files in the "bad" copy, don't
forget to copy those out and into the newly cloned
copy
i'm a fairly sophisticated git user. i've been using it for
over 10 year, have given multiple conference talks on
git, have led trainings on git, and i've managed to
screw things up in a repo so badly that i've done this
"just re-clone it" more than once in the last year.
there's no shame in doing this; sometimes things just
get so bollixed up that it's easier to start over than to
unbollix them.
two: rename your repo directory
(from ‘repo’ to ‘repo.bad’)
and then re-clone the repo
95 — intro to git — os101/columbia — @genehack
review
96 — intro to git — os101/columbia — @genehack
git status
97 — intro to git — os101/columbia — @genehack
git add
98 — intro to git — os101/columbia — @genehack
git commit
99 — intro to git — os101/columbia — @genehack
git diff
100 — intro to git — os101/columbia — @genehack
git log
101 — intro to git — os101/columbia — @genehack
additional
resources
102 — intro to git — os101/columbia — @genehack
git-scm.com
103 — intro to git — os101/columbia — @genehack
hellowebbooks.com/learn-command-line
104 — intro to git — os101/columbia — @genehack
try.github.io
105 — intro to git — os101/columbia — @genehack
git-scm.com/book
106 — intro to git — os101/columbia — @genehack
thanks
107 — intro to git — os101/columbia — @genehack
os101organizers108 — intro to git — os101/columbia — @genehack
you!109 — intro to git — os101/columbia — @genehack
interested in an
internship?
iinteractive.com/internship
111 — intro to git — os101/columbia — @genehack
questions?

More Related Content

What's hot

Eat my data
Eat my dataEat my data
Eat my data
Peng Zuo
 
T3DD13 - Automated deployment for TYPO3 CMS (Workshop)
T3DD13 - Automated deployment for TYPO3 CMS (Workshop)T3DD13 - Automated deployment for TYPO3 CMS (Workshop)
T3DD13 - Automated deployment for TYPO3 CMS (Workshop)
Tobias Liebig
 
Ankara jug mayıs 2013 sunumu
Ankara jug mayıs 2013 sunumuAnkara jug mayıs 2013 sunumu
Ankara jug mayıs 2013 sunumu
Ankara JUG
 

What's hot (19)

That's (g)it! par Sébastien Dawans CETIC
That's (g)it! par Sébastien Dawans CETICThat's (g)it! par Sébastien Dawans CETIC
That's (g)it! par Sébastien Dawans CETIC
 
GIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control SystemGIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control System
 
Versions
VersionsVersions
Versions
 
Git & git hub
Git & git hubGit & git hub
Git & git hub
 
setting up a repository using GIT
setting up a repository using GITsetting up a repository using GIT
setting up a repository using GIT
 
Eat my data
Eat my dataEat my data
Eat my data
 
Git real slides
Git real slidesGit real slides
Git real slides
 
git入門取得編
git入門取得編git入門取得編
git入門取得編
 
T3DD13 - Automated deployment for TYPO3 CMS (Workshop)
T3DD13 - Automated deployment for TYPO3 CMS (Workshop)T3DD13 - Automated deployment for TYPO3 CMS (Workshop)
T3DD13 - Automated deployment for TYPO3 CMS (Workshop)
 
Git Real
Git RealGit Real
Git Real
 
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
Scalable Deployment Architectures with TYPO3 Surf, Git and JenkinsScalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
 
Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
 
Gorush: A push notification server written in Go
Gorush: A push notification server written in GoGorush: A push notification server written in Go
Gorush: A push notification server written in Go
 
用 Go 語言實戰 Push Notification 服務
用 Go 語言實戰 Push Notification 服務用 Go 語言實戰 Push Notification 服務
用 Go 語言實戰 Push Notification 服務
 
Continuous Delivery of Puppet Manifests
Continuous Delivery of Puppet ManifestsContinuous Delivery of Puppet Manifests
Continuous Delivery of Puppet Manifests
 
T3CON12 Flow and TYPO3 deployment with surf
T3CON12 Flow and TYPO3 deployment with surfT3CON12 Flow and TYPO3 deployment with surf
T3CON12 Flow and TYPO3 deployment with surf
 
Git meanings of -distributed-
Git  meanings of -distributed-Git  meanings of -distributed-
Git meanings of -distributed-
 
Git slides
Git slidesGit slides
Git slides
 
Ankara jug mayıs 2013 sunumu
Ankara jug mayıs 2013 sunumuAnkara jug mayıs 2013 sunumu
Ankara jug mayıs 2013 sunumu
 

Similar to Introduction to Git for Non-Developers

Similar to Introduction to Git for Non-Developers (20)

Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdf
 
Introduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticleIntroduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech Article
 
git & GitHub workshop
git & GitHub workshopgit & GitHub workshop
git & GitHub workshop
 
Gitting better
Gitting betterGitting better
Gitting better
 
Git for a newbie
Git for a newbieGit for a newbie
Git for a newbie
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
 
Hacktoberfest 2020 - Open source for beginners
Hacktoberfest 2020 - Open source for beginnersHacktoberfest 2020 - Open source for beginners
Hacktoberfest 2020 - Open source for beginners
 
Workshop on Source control, git merge walkthroughs
Workshop on Source control, git merge walkthroughsWorkshop on Source control, git merge walkthroughs
Workshop on Source control, git merge walkthroughs
 
Git
GitGit
Git
 
1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx
 
Git essentials
Git essentialsGit essentials
Git essentials
 
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a gitVincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Getting started With GIT
Getting started With GITGetting started With GIT
Getting started With GIT
 
GitHub Event.pptx
GitHub Event.pptxGitHub Event.pptx
GitHub Event.pptx
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptx
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
16 Git
16 Git16 Git
16 Git
 
git and github
git and githubgit and github
git and github
 

More from All Things Open

Open Source and Public Policy
Open Source and Public PolicyOpen Source and Public Policy
Open Source and Public Policy
All Things Open
 
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
All Things Open
 
How to Write & Deploy a Smart Contract
How to Write & Deploy a Smart ContractHow to Write & Deploy a Smart Contract
How to Write & Deploy a Smart Contract
All Things Open
 
Scaling Web Applications with Background
Scaling Web Applications with BackgroundScaling Web Applications with Background
Scaling Web Applications with Background
All Things Open
 
Build Developer Experience Teams for Open Source
Build Developer Experience Teams for Open SourceBuild Developer Experience Teams for Open Source
Build Developer Experience Teams for Open Source
All Things Open
 
Sudo – Giving access while staying in control
Sudo – Giving access while staying in controlSudo – Giving access while staying in control
Sudo – Giving access while staying in control
All Things Open
 
Fortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML ApplicationsFortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML Applications
All Things Open
 
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
All Things Open
 

More from All Things Open (20)

Building Reliability - The Realities of Observability
Building Reliability - The Realities of ObservabilityBuilding Reliability - The Realities of Observability
Building Reliability - The Realities of Observability
 
Modern Database Best Practices
Modern Database Best PracticesModern Database Best Practices
Modern Database Best Practices
 
Open Source and Public Policy
Open Source and Public PolicyOpen Source and Public Policy
Open Source and Public Policy
 
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
Weaving Microservices into a Unified GraphQL Schema with graph-quilt - Ashpak...
 
The State of Passwordless Auth on the Web - Phil Nash
The State of Passwordless Auth on the Web - Phil NashThe State of Passwordless Auth on the Web - Phil Nash
The State of Passwordless Auth on the Web - Phil Nash
 
Total ReDoS: The dangers of regex in JavaScript
Total ReDoS: The dangers of regex in JavaScriptTotal ReDoS: The dangers of regex in JavaScript
Total ReDoS: The dangers of regex in JavaScript
 
What Does Real World Mass Adoption of Decentralized Tech Look Like?
What Does Real World Mass Adoption of Decentralized Tech Look Like?What Does Real World Mass Adoption of Decentralized Tech Look Like?
What Does Real World Mass Adoption of Decentralized Tech Look Like?
 
How to Write & Deploy a Smart Contract
How to Write & Deploy a Smart ContractHow to Write & Deploy a Smart Contract
How to Write & Deploy a Smart Contract
 
Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
 Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
Spinning Your Drones with Cadence Workflows, Apache Kafka and TensorFlow
 
DEI Challenges and Success
DEI Challenges and SuccessDEI Challenges and Success
DEI Challenges and Success
 
Scaling Web Applications with Background
Scaling Web Applications with BackgroundScaling Web Applications with Background
Scaling Web Applications with Background
 
Supercharging tutorials with WebAssembly
Supercharging tutorials with WebAssemblySupercharging tutorials with WebAssembly
Supercharging tutorials with WebAssembly
 
Using SQL to Find Needles in Haystacks
Using SQL to Find Needles in HaystacksUsing SQL to Find Needles in Haystacks
Using SQL to Find Needles in Haystacks
 
Configuration Security as a Game of Pursuit Intercept
Configuration Security as a Game of Pursuit InterceptConfiguration Security as a Game of Pursuit Intercept
Configuration Security as a Game of Pursuit Intercept
 
Scaling an Open Source Sponsorship Program
Scaling an Open Source Sponsorship ProgramScaling an Open Source Sponsorship Program
Scaling an Open Source Sponsorship Program
 
Build Developer Experience Teams for Open Source
Build Developer Experience Teams for Open SourceBuild Developer Experience Teams for Open Source
Build Developer Experience Teams for Open Source
 
Deploying Models at Scale with Apache Beam
Deploying Models at Scale with Apache BeamDeploying Models at Scale with Apache Beam
Deploying Models at Scale with Apache Beam
 
Sudo – Giving access while staying in control
Sudo – Giving access while staying in controlSudo – Giving access while staying in control
Sudo – Giving access while staying in control
 
Fortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML ApplicationsFortifying the Future: Tackling Security Challenges in AI/ML Applications
Fortifying the Future: Tackling Security Challenges in AI/ML Applications
 
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
Securing Cloud Resources Deployed with Control Planes on Kubernetes using Gov...
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

Introduction to Git for Non-Developers

  • 1. an introduction to git (even for non-developers) john sj anderson · @genehack · os101/columbia • 17 apr 2018 1 — intro to git — os101/columbia — @genehack
  • 2. vp of tech, infinity interactive custom software development and technology consulting hi, i’m john. also known as @genehack 2 — intro to git — os101/columbia — @genehack
  • 3. do you identify as a non-developer? developer? something in between? no experience with git? some experience? consider yourself a git expert? for those w/git experience, how many of you are anxious about git? let’s start out with an audience survey3 — intro to git — os101/columbia — @genehack
  • 4. simplify and de-mystify git open source desperately needs non- developer contributions, but git anxiety can block or slow down otherwise helpful contributions. i'd like to help people understand git a little bit better, to work to reduce that barrier to entry my goals for this talk4 — intro to git — os101/columbia — @genehack
  • 5. going to talk about how you get a git repository to work on adding and changing files sending changes back up to the original branching and merging saving your bacon when things go pear- shaped additional resources talkoverview5 — intro to git — os101/columbia — @genehack
  • 6. this is a tough topic. there's lots of jargon i'm going to try to explain things in different terms than are normally used to ease that a bit. trying really hard to avoid saying "just", "simple", "easy", etc. please help me here. ground rules6 — intro to git — os101/columbia — @genehack
  • 7. what is git?7 — intro to git — os101/columbia — @genehack
  • 8. this definition has the unique combination of being 100% accurate and also being completely useless unless you already know what it means. so if you don't already know what it means, you will be forgiven if your reaction to this definition is ... distributed revision control system 8 — intro to git — os101/columbia — @genehack
  • 9. 9
  • 11. let's break this down into a couple of parts. first, let's consider 'revision control system'. what's a revision control system? distributed revision control system 11 — intro to git — os101/columbia — @genehack
  • 12. 12 — intro to git — os101/columbia — @genehack
  • 13. revision control systems (rcs, cvs, svn, tfs, git, etc) are a fundamental building block of software development. 13 — intro to git — os101/columbia — @genehack
  • 14. <insert rant about how this stuff should be taught in school> a brief aside14 — intro to git — os101/columbia — @genehack
  • 15. ok, so that's 'revision control system' -- what about the 'distributed' part? what's that mean? distributed revision control system 15 — intro to git — os101/columbia — @genehack
  • 16. 16 — intro to git — os101/columbia — @genehack
  • 17. another brief aside 17 — intro to git — os101/columbia — @genehack
  • 18. git is a really nice fit for any kind of text- based stuff that changes over time -- websites, recipes, writing, your resume, etc. git will even work okay with binary formats, it's just a bit harder to see some of the changes that happen that way. git’s not only for code.18 — intro to git — os101/columbia — @genehack
  • 19. git is also not github.19 — intro to git — os101/columbia — @genehack
  • 20. also not bitbucker, not team foundation server all of these are sites that provide hosting for git-based projects along with a number of other project management tools. git is also not gitlab.20 — intro to git — os101/columbia — @genehack
  • 21. they're way bigger than the scope of this talk, and the material in this talk applies equally to any of them. i encourage you to initially focus on learning the basics of git, and only then start to focus on the git hosting site you (or the project you've chosen to work on) have decided to use. learning the basics of git will help you regardless of what git hosting is used 21 — intro to git — os101/columbia — @genehack
  • 22. so, one of the initial things you need to do, if you don't already have git installed, is to get git. getting git22 — intro to git — os101/columbia — @genehack
  • 23. you can do this by going to git- scm.com... note that i will put these slides up for download after the talk, and tweet out the location, so you don't need to worry about writing down each url... git-scm.com
  • 24. where they will have links to install it for whatever platform you're on. if you're running something with a package manager (linux, mac with brew, etc.) just using the package manager may be easier. you may also see that they have links here to 'Mac GUIs'...
  • 25. ...so this is a good time to talk about GUI git versus CLI git. after thinking about this for a bit, i decided to give all the examples in this talk in terms of the CLI. that was for a few reasons: when you need to do a net search for help with something, most of the results will be given in terms of the CLI, so having a basic understanding will help showing a GUI in addition to the CLI examples would effectively halve the amount of stuff i can get through (and the talk is already groaning when jammed into a 30 minute slot) there are a bunch of Git GUIs and this way i didn't have to pick just one to show cli versus gui25 — intro to git — os101/columbia — @genehack
  • 26. aside: if you're not familiar with the CLI, it's a useful skill to have as an open source contributor, even as a non- developer. Tracy Osborn, who has done some nice intro web design and web programming books, just recently released a free e-book called "really friendly command line intro" 26
  • 27. you can grab a copy here -- and again, slides available online later, so you don't have to copy this down. hellowebbooks.com/learn-command-line 27
  • 28. before we do anything else, we need to tell git who we are 28 — intro to git — os101/columbia — @genehack
  • 29. git config is a git command for modifying configuration values. in this case, we're giving it the -- global flag to indicate that we want to modify the configuration for any use of git. and then we set the user.name and user.email values to our name and email. this information is needed because once we start making changes (here in a few slides), git is going to track who made what change. if you don't provide these values for it, sometimes git will try to guess, and it will probably get it wrong. (and when it doesn't guess, it will just refuse to work until you run the above commands.) git config --global user.name "Put your name here" git config --global user.email "email@example.com" 29 — intro to git — os101/columbia — @genehack
  • 30. now that we've got the required git configuration done, we need to get a repository to work on. step one: obtaining a repository 30 — intro to git — os101/columbia — @genehack
  • 31. oh, wait, there's some jargon. what's a "repository"? a repository is just what git calls a project, or a directory where the contents are under the control of git you'll also hear people say "repo" because "repository" is an annoyingly long word to have to type out a bunch jargon: repository31 — intro to git — os101/columbia — @genehack
  • 32. 'clone' is what git calls making a copy of somebody else's existing repository. this is typically what you'll do if you want to contribute to an open source project -- you'll make a clone of the project's repo so that you can look at what's there, and possibly change it and contribute it back to the project. first option: clone32 — intro to git — os101/columbia — @genehack
  • 33. this is the github page for an open source project -- one that happen's to be one of mine, a perl module for interacting with git. if you click this green button here...
  • 34. ...you'll get a little popup with a URL you can copy...
  • 35. ...and in fact this little circled button here does just that, copies the URL to the clipboard for you.
  • 36. then you can open up a terminal and run the following command to clone the repository git clone <url> 36 — intro to git — os101/columbia — @genehack
  • 37. and here's the output you'll see when you do. this first line tells you it's cloning into a directory named 'Git-Wrapper' in the current working directory, and the other lines here are just stats about the size of the repository, basically. $ git clone https://github.com/genehack/Git-Wrapper.git Cloning into 'Git-Wrapper'... remote: Counting objects: 4067, done. remote: Compressing objects: 100% (23/23), done. remote: Total 4067 (delta 16), reused 33 (delta 16), pack-reused 4028 Receiving objects: 100% (4067/4067), 3.20 MiB | 5.80 MiB/s, done. Resolving deltas: 100% (1917/1917), done. 37 — intro to git — os101/columbia — @genehack
  • 38. the other option for getting a repository is to create a fresh, new empty one second option: diy38 — intro to git — os101/columbia — @genehack
  • 39. you do that with the 'git init' command. it will create a new repo in a directory named for the project git init <project-name> 39 — intro to git — os101/columbia — @genehack
  • 40. so, as you can see here, when we run the command, it creates the directory for us the directory contains only .git .git contains a bunch of stuff you can ignore all of this for the moment, but you need to understand that the .git directory is where git stores all the data about the repository itself. if you remove the .git directory, you turn the repo into just an ordinary directory containing files. $ git init my-new-project Initialized empty Git repository in /Users/genehack/my-new-project/.git/ $ ls -a my-new-project ./ ../ .git/ $ ls -a my-new-project/.git ./ ../ HEAD branches/ config description hooks/ info/ objects/ refs/ 40 — intro to git — os101/columbia — @genehack
  • 41. ok, now we have a repo! yay! ok, now we have a repo41 — intro to git — os101/columbia — @genehack
  • 42. let's keep working with the fresh new empty repo. the first thing we need to do is add a file to it. let's add a README file with some basic info about the project README files are traditionally found in the top level of a repository and contain basic introductory material about the project -- what problems it aims to solve, how to use it, maybe instructions on how to contribute back to the project, etc. so let's make that file... let’s add a file to it42 — intro to git — os101/columbia — @genehack
  • 43. yes, yes, i'm an emacs user. so, let's pretend we write some basic stuff in the README.md and save it photo credit: https:// www.flickr.com/photos/rore/ 4457009838 (cc/by/2.0) emacs README.md 43 — intro to git — os101/columbia — @genehack
  • 44. we need to ask git what's going on with the repository. the way we do that ... next, we need to ask git “sup?”44 — intro to git — os101/columbia — @genehack
  • 45. ...is with a command called git status git status 45 — intro to git — os101/columbia — @genehack
  • 46. when we run git status, we see that git is telling us, "hey, there's this file here, but you haven't told me to track it or anything -- just letting you know, i see it" git also helpfully tells you, "hey, if you want me to be be tracking it, you need to git add it"... $ git status On branch master No commits yet Untracked files: (use "git add <file>..." to include in what will be committed) README.md nothing added to commit but untracked files present (use "git add" to track) 46 — intro to git — os101/columbia — @genehack
  • 47. so let's run that command next, git add git add README.md 47 — intro to git — os101/columbia — @genehack
  • 48. and then check the status again git status 48 — intro to git — os101/columbia — @genehack
  • 49. and now we can see git is telling us, "yo, got a new file here!" $ git status On branch master No commits yet Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: README.md 49 — intro to git — os101/columbia — @genehack
  • 50. if you look at the documentation for git add, you'll see something like this: <read slide> git add stages changes to be committed 50 — intro to git — os101/columbia — @genehack
  • 51. there's another piece of jargon to break down -- "staging area" " jargon: staging area51 — intro to git — os101/columbia — @genehack
  • 52. you can even see here, in the git status output, git is telling us how to "unstage" something On branch master No commits yet Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: README.md 52 — intro to git — os101/columbia — @genehack
  • 53. to get this jargon, you need to understand the different states git thinks files can be in, or the lifecycle that a file moves through the lifecycle of file changes according to git 53 — intro to git — os101/columbia — @genehack
  • 54. as we saw, when we create a new file, it ends up in a state called "untracked". untracked staged committed54 — intro to git — os101/columbia — @genehack
  • 55. and git add is what takes us out of that "untracked" state, and puts us into "staged". "staged" is an area in between 'untracked' and 'committed', which allows you to build up what's going to be in a commit piece by piece. this isn't something you'll care too much about when you're just getting started. ‘git add’ takes you from “untracked” to “staged”55 — intro to git — os101/columbia — @genehack
  • 56. so how do we go from “staged” to “committed”? 56 — intro to git — os101/columbia — @genehack
  • 57. git commit 57 — intro to git — os101/columbia — @genehack
  • 58. the commit message is going to describe what's in the commit, and possibly why the change is being made this is the part where your name and email address -- the stuff we fed into git config way back when -- comes into play git wants commits to have an accompanying commit message 58 — intro to git — os101/columbia — @genehack
  • 59. by default, cli git uses vimto write commit messages 59 — intro to git — os101/columbia — @genehack
  • 60. https://twitter.com/ thepracticaldev/status/ 747871086478516226? lang=en if you’re not already a vim userthis is probably not what you want. 60 — intro to git — os101/columbia — @genehack
  • 61. instead you can use the -m flag and give the commit message as part of the command git commit -m "<your message here>" 61 — intro to git — os101/columbia — @genehack
  • 62. to review, git add... git add takes files from “untracked” to “staged” 62 — intro to git — os101/columbia — @genehack
  • 63. ...and git commit git commit takes files from “staged” to “committed” 63 — intro to git — os101/columbia — @genehack
  • 64. so that covers adding a file to the repo. what if we need to revise it? so, what about edits?64 — intro to git — os101/columbia — @genehack
  • 65. pretend we edit the file again, and ... emacs README.md 65 — intro to git — os101/columbia — @genehack
  • 66. we ask git, "sup?" git status 66 — intro to git — os101/columbia — @genehack
  • 67. and we see something new! git tells us the file has been modified $ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: README.md no changes added to commit (use "git add" and/or "git commit -a") 67 — intro to git — os101/columbia — @genehack
  • 68. so let's return to our lifecycle... the lifecycle of file changes according to git 68 — intro to git — os101/columbia — @genehack
  • 69. ...and we need to add a fourth state, modified. so we have untracked, staged, committed, and modified. untracked staged committed modified 69 — intro to git — os101/columbia — @genehack
  • 70. you might wonder, since git knows the file is changed, can it tell you how it was changed? can we ask git “yo, what changed?” 70 — intro to git — os101/columbia — @genehack
  • 71. and yes, it can, with a command called 'git diff'. git diff 71 — intro to git — os101/columbia — @genehack
  • 72. <briefly walk through diff> $ git diff diff --git a/README.md b/README.md index bf3d7ca..9a71af8 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ # My Awesome New Project + +**FIXME:** write README 72 — intro to git — os101/columbia — @genehack
  • 73. at this point, to get the changes to README.md committed, you're going to do the exact same steps as with adding the file for the first time: you're going to use 'git add' to stage the change, and then you're going to use 'git commit' to commit it. adding and editing files is notvery different73 — intro to git — os101/columbia — @genehack
  • 74. first we stage the changes git add README.md 74 — intro to git — os101/columbia — @genehack
  • 75. and then we commit them git commit -m "<explain the change>" 75 — intro to git — os101/columbia — @genehack
  • 76. git records the commit messages and then lets you look back at them. this is called the 'history' of the repository. when you're first getting involved with a new open source project, taking some time to read over the recent history of the repo is a great way to get up to speed -- you'll see which files have changed recently, and see who's actually doing the work to put in the changes so, what's going on with those commit messages?76 — intro to git — os101/columbia — @genehack
  • 77. the way you look at the history is with a command called git log. running it ends up looking like this: git log 77 — intro to git — os101/columbia — @genehack
  • 78. $ git log commit f2645941f26ab276bed99b12f170e97ca9c90106 Author: John SJ Anderson <john@genehack.org> Date: Sat Apr 14 17:04:36 2018 -0400 Update README with FIXME commit 3e805602660713b8f98f610cf178df70c2ceb91f Author: John SJ Anderson <john@genehack.org> Date: Sun Apr 15 07:00:14 2018 -0400 Add README.md 78 — intro to git — os101/columbia — @genehack
  • 79. you can also include the -p flag -- for patch -- to ask git to show you the exact lines that were changed in each commit. that looks like... git log -p 79 — intro to git — os101/columbia — @genehack
  • 80. $ git log -p commit f2645941f26ab276bed99b12f170e97ca9c90106 Author: John SJ Anderson <john@genehack.org> Date: Sat Apr 14 17:04:36 2018 -0400 Update README with FIXME diff --git a/README.md b/README.md index bf3d7ca..9a71af8 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ # My Awesome New Project + +**FIXME:** write README 80 — intro to git — os101/columbia — @genehack
  • 81. commit 3e805602660713b8f98f610cf178df70c2ceb91f Author: John SJ Anderson <john@genehack.org> Date: Sun Apr 15 07:00:14 2018 -0400 Add README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..bf3d7ca --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# My Awesome New Project 81 — intro to git — os101/columbia — @genehack
  • 82. a few more concepts 82 — intro to git — os101/columbia — @genehack
  • 83. branches 83 — intro to git — os101/columbia — @genehack
  • 84. a branch is a new working copy of your repo 84 — intro to git — os101/columbia — @genehack
  • 85. branches allow you to make changes without altering the underlying master copy85 — intro to git — os101/columbia — @genehack
  • 86. when the work on the branch passes review, you need to merge86 — intro to git — os101/columbia — @genehack
  • 87. pushing 87 — intro to git — os101/columbia — @genehack
  • 88. pushing means sending changes to some other copy of the repository 88 — intro to git — os101/columbia — @genehack
  • 89. the repository you're pushing changes to is called a remote89 — intro to git — os101/columbia — @genehack
  • 90. pull request 90 — intro to git — os101/columbia — @genehack
  • 91. a request to merge your changes into their repository 91 — intro to git — os101/columbia — @genehack
  • 92. what to do when things go bad 92 — intro to git — os101/columbia — @genehack
  • 93. two fixes that (almost) always work93 — intro to git — os101/columbia — @genehack
  • 94. the first approach is good when you've got things into a bad state and you think you know the fix but are worried that you're going to mess things up worse: make a copy, try the fix on the copy, and then if it works, do it to actual directory. (and if it fails, throw away the copy and try something else!) one: make a copy of your repo & try a fix on the copy 94 — intro to git — os101/columbia — @genehack
  • 95. if you have modified files in the "bad" copy, don't forget to copy those out and into the newly cloned copy i'm a fairly sophisticated git user. i've been using it for over 10 year, have given multiple conference talks on git, have led trainings on git, and i've managed to screw things up in a repo so badly that i've done this "just re-clone it" more than once in the last year. there's no shame in doing this; sometimes things just get so bollixed up that it's easier to start over than to unbollix them. two: rename your repo directory (from ‘repo’ to ‘repo.bad’) and then re-clone the repo 95 — intro to git — os101/columbia — @genehack
  • 96. review 96 — intro to git — os101/columbia — @genehack
  • 97. git status 97 — intro to git — os101/columbia — @genehack
  • 98. git add 98 — intro to git — os101/columbia — @genehack
  • 99. git commit 99 — intro to git — os101/columbia — @genehack
  • 100. git diff 100 — intro to git — os101/columbia — @genehack
  • 101. git log 101 — intro to git — os101/columbia — @genehack
  • 102. additional resources 102 — intro to git — os101/columbia — @genehack
  • 103. git-scm.com 103 — intro to git — os101/columbia — @genehack
  • 104. hellowebbooks.com/learn-command-line 104 — intro to git — os101/columbia — @genehack
  • 105. try.github.io 105 — intro to git — os101/columbia — @genehack
  • 106. git-scm.com/book 106 — intro to git — os101/columbia — @genehack
  • 107. thanks 107 — intro to git — os101/columbia — @genehack
  • 108. os101organizers108 — intro to git — os101/columbia — @genehack
  • 109. you!109 — intro to git — os101/columbia — @genehack
  • 110.
  • 111. interested in an internship? iinteractive.com/internship 111 — intro to git — os101/columbia — @genehack