Professional Documents
Culture Documents
Full Ebook of Oh Shit Git Katie Sylor Miller Online PDF All Chapter
Full Ebook of Oh Shit Git Katie Sylor Miller Online PDF All Chapter
Full Ebook of Oh Shit Git Katie Sylor Miller Online PDF All Chapter
https://ebookmeta.com/product/unbull-shit-yourself-1st-edition-
wakabi-kevin/
https://ebookmeta.com/product/practical-git-confident-git-
through-practice-1st-edition-johan-abildskov/
https://ebookmeta.com/product/advanced-git-understanding-git-
collaboration-workflows-2nd-edition-jawwad-ahmad/
https://ebookmeta.com/product/git-prodigy-mastering-version-
control-with-git-and-github-ebenezer-don/
Git Apprentice Getting Started with Git Commands
Concepts 1st Edition Chris Belanger
https://ebookmeta.com/product/git-apprentice-getting-started-
with-git-commands-concepts-1st-edition-chris-belanger/
https://ebookmeta.com/product/git-essentials-developer-s-guide-
to-git-1st-edition-francois-dupire/
https://ebookmeta.com/product/git-apprentice-getting-started-
with-git-commands-concepts-1st-edition-chris-belanger-2/
https://ebookmeta.com/product/learning-git-a-visual-approach-for-
using-git-successfully-second-early-release-anna-skoulikari/
https://ebookmeta.com/product/learning-git-a-hands-on-and-visual-
guide-to-the-basics-of-git-anna-skoulikari/
what's this
If you find git confusing, don't worry! You're not alone.
People who've been using it every day for years still
make mistakes and aren't sure how to fix them.
A lot of git commands are confusingly named (why do
you create new branches with git checkout?) and
there are 20 million different ways to do everything.
slmansitreset
In the first and second
form, copy entries from
<tree-ish> to the index. In
the third form, set the
current branch head (HEAD)
to <commit>, optionally
modifying index and
omaybegitreseH.fm working tree to match. The
<tree-ish>/<commit>
actual
0 defaults to HEAD in all
forms.
g
manpage eviesnthnisglish
Tien oes
t t
n n
Katie Julia
By Katie Sylor-Miller & Julia Evans
Website: https://ohshitgit.com
Cover art by Deise Lino
Table of contents
git fundamentals
a SHA is
always the same code 4
every commit has a parent commit 5
a branch reference to a commit
is a 6
HEAD is the commit you have checked out 7
mistakes you can't fix 8
Emmet
out a SHA will always give you the exact same code. It's
like saving your game so that you can go back if you die
You can check out a commit like this: SHAs are long
but you can
git checkout 3f29ab just use the
first 6chars
This makes it way easier to recover from mistakes!
IIOamJ 1lam
qgoeothnietisaii.mzitsmhaEiIioTg.e
4
A branch is a
pointer
to a commit
A branch in git is a pointer to a commit SHA
$ cat .git/refs/heads/master
t
this is just a text file
with the comimit SHAmaster
points at B
EITnenm.tt
2abcdeJ HEAD make cats blue
to
parent Tfeefffe HEAD add cats
f
ent la9J2eab HEAD
Grapnadr
fix typo
a git clean
or directory
git checkout BRANCH FILE
8
I need to change the message
f
fyard my last commit.ir
on
i
git commit --amend I
I
if you run
git commit but change
EIIIIifIIinifigffiatingigassibitsalisnstauitting
I
fsfFL.s I committed but I neyed to
gf
yard
make one small change
i
git commit --amend --no-edit i
re
oh s.tsii
rqgiethisoi.si
enJ
before committing9
I
I accidentally committed
to the
gffffffs wrongbranch
yard
Check out the correct branch correct i throng
ri
git checkout correct-branch
cherrypick makes a
new commit with the
Same changes as A
but a differentparent
Add the commit you wanted to it I
correct
wrong
git cherry-pick COMMIT_ID
f
use git logwrong branch
to find this
Delete the commit from the wrong branch
correFF
git checkout wrong-branch wrong
git reset --hard HEAD^ I
i
I
I committed something to
fFF master that should have been
git status
git reset --hard HEAD~
careful
T
i iti i en
12
I tried to run diffa
f
fyard but nothing happened
ai
i
Suppose you've edited 2 files I
$ git status
On branch master
Changes to be committed: staged changes
added with
modified: staged.txt it add
Changes not staged for commit: g
unstaged
modified: unstaged.txt
changes
Here are the 3 ways git can show you a diff for
these changes:
p
git diff --staged: staged changes
B git diff HEAD: staged+unstaged changes
p
git diff --stat gives you a summary of
which files were changed & number of
added/deleted lines
p git diff --check checks for merge
conflict markers & whitespace errors
13
Ihave a
JIFFIES merge conflict
yard
Suppose you had master checked out and ran
git merge feature-branch.
When that causes a merge conflict, you'll see
something like this in the files with conflicts:
<<<<<<< HEAD
if x == 0:
return false code from master
=======
if y == 6:
return true
elif x ==0:
return false Euterimanan
>>>>>>>> d34367
To resolve the conflict:
j isIoo
Meld lmeldmerge.org is
A a
greatchoice
14
I committed a file that
gfjff.IS
yard
should be ignored 9
15
I started rebasing and
f
f Tf I have
now 10000000
B
conflicts to fix
This can happen when you're rebasing many
commits at once.
i
want to
fsfFEk.Icommit split my
gfperf into 2 commits
git stash
ii
17
I want to undo something
fF
fyard from 5 commits ago
Run:
git revert SHA
i
I did something terribly wrong
fFE does git have a magic
perf time machine
Yes! It's called git reflog and it logs every single thing
you do with git so that you can always go back.
i
245fc8d HEAD@{2} rebase -i (start): checkout master
b623930 HEAD@{3} commit: add cool feature
01d7933 HEAD@{4} checkout: moving from master
to my-cool-branch
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must, at
no additional cost, fee or expense to the user, provide a copy, a
means of exporting a copy, or a means of obtaining a copy upon
request, of the work in its original “Plain Vanilla ASCII” or other
form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.