Fireship · @fireship
Git Explained in 100 Seconds
Uploaded March 2, 2020 · Length 1:57
Summary
git basics: creating commits, branches, and merging in a codebase.
- git
- version control
- commit
- branch
- merge
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
get a system for keeping track of
- 0:02
changes that happen across a set of
- 0:03
files open a directory on your local
- 0:05
system with an editor like vs code then
- 0:07
run get an it from the command line you
- 0:09
just created a git repository or repo it
- 0:12
lives in this hidden get directory and
- 0:13
keeps track of all the changes that
- 0:15
happen to these files as you work on a
- 0:17
codebase you take snapshots or commits
- 0:19
of the current state of these files
- 0:20
every commit has a unique ID and is
- 0:22
linked to its parent and this means we
- 0:24
can travel back in time to a previous
- 0:26
version of our files notice how our
- 0:27
source control icon is lit up currently
- 0:29
all of our files are untracked because
- 0:31
we need to add them to the repo run get
- 0:33
add to include or stage these files in
- 0:35
the repo then create a snapshot of their
- 0:37
current state by running git commit
- 0:39
along with a message about what you did
- 0:41
to these files congratulations
- 0:43
you just created the first commit on the
- 0:44
head of the master branch in this repo
- 0:46
the changed files disappeared and you're
- 0:48
now on a clean working directory the
- 0:49
head represents the most recent commit
- 0:51
if we make some changes commit them to
- 0:53
the repo the head moves forward but we
- 0:55
still have a reference to our previous
- 0:56
commits so we can always go back to it
- 0:58
but the thing about software is that
- 1:00
it's developed in a nonlinear fashion
- 1:01
you might have multiple teams working on
- 1:03
different features for the same codebase
- 1:05
simultaneously it makes that possible by
- 1:08
branching create one by running git
- 1:10
branch and then rank it check out to
- 1:12
move into that branch you can now safely
- 1:13
work on your feature in this branch
- 1:15
without affecting the code or files in
- 1:17
the master branch the commits you make
- 1:19
here live in an alternate universe with
- 1:20
its own unique history at some point
- 1:22
though you'll likely want to merge this
- 1:24
history with the history and the master
- 1:25
branch when you're ready go back to the
- 1:27
master branch by running git checkout
- 1:28
then run git merge on your
- 1:30
alternate-universe
- 1:31
the tip of your feature branch now
- 1:33
becomes the head of the master branch
- 1:34
where in other words our fragmented
- 1:36
universe has become one unless he ran
- 1:39
into a merge conflict in which case
- 1:40
you'll just have to wait for the sequel
- 1:42
this has been get explained in 100
- 1:44
seconds if you want to see more short
- 1:46
videos like this make sure to hit the
- 1:47
like button subscribe and let me know
- 1:49
what you think in the comments thanks
- 1:50
for watching and I will see you in the
- 1:52
next one
- 1:55
you


