Git Tutorial For Dummies
Summary
TLDRThis video script offers a simplified explanation of Git and GitHub, essential tools for programmers. The presenter breaks down complex concepts into digestible parts, likening Git to a 'memory card for code' to save progress locally. They introduce basic Git commands, such as 'git init', 'git add', and 'git commit', to track changes. The script also touches on GitHub as a platform for sharing code and collaborating with others, explaining how to push and pull changes. The tutorial aims to demystify version control for beginners, emphasizing the importance of these tools in programming.
Takeaways
- 😀 Git and GitHub are two different things, with Git being a local version control system and GitHub being a remote platform for hosting and collaborating on code.
- 🛠️ Git is essential for programming; it's like a 'memory card' for saving the progress of your code locally on your computer.
- 📁 Git Bash is necessary for Windows users to access Git, as it's not pre-installed like on Mac or Linux systems.
- 🔧 Basic Git commands include 'git init' to start a new repository, 'git add' to stage changes, and 'git commit' to save those changes with a message.
- 📝 The 'git log' command allows you to view the history of commits, which is useful for tracking changes over time.
- 🔄 'git checkout' can be used to revert to a previous commit or state of the project, but it puts you on a different 'branch' of the timeline.
- 🌐 GitHub is a platform for sharing code with others, allowing you to push your local commits to a remote repository where others can access them.
- 🔄 'git pull' is used to update your local repository with changes from GitHub, while 'git push' uploads your local changes to the remote repository.
- 🔄 Branches in Git allow for diverging from the main code without affecting it, enabling multiple people to work on different features or fixes simultaneously.
- 🔀 Merging branches combines changes from one branch into another, often used to integrate contributions from others into the main codebase.
- 📊 GitHub 'green squares' represent commits made to a repository each day, but they don't necessarily reflect the quality or impact of the contributions.
Q & A
What is the primary purpose of Git according to the video?
-Git serves as a 'memory card' for code, allowing developers to save their progress locally on their computers, ensuring they don't lose work if files are accidentally deleted.
Why is Git essential for programming?
-Git is essential for programming because it is one of the most basic tools needed for version control, alongside terminal and command line skills, and is necessary for successful programming.
What does the 'git init' command do?
-The 'git init' command initializes an existing directory as a Git repository, setting it up to track changes with Git.
What does 'git add .' do in the context of the video?
-The 'git add .' command stages all changes made in the project since the last commit, preparing them to be saved with the next 'git commit' command.
Outlines
🤓 Simplifying Git for Beginners
The speaker introduces Git as an essential tool for programmers, comparing it to a memory card for saving code progress. They emphasize that Git comes pre-installed on Mac and Linux systems, while Windows users need to download Git Bash. The tutorial aims to simplify Git concepts, starting with basic commands like 'git init' to set up a repository and 'git add' followed by 'git commit' to save changes, including the use of commit messages for clarity. The speaker also demonstrates how to revert to previous versions of code using 'git log' and 'git checkout', providing a practical example of creating and managing files within a project.
🔄 Understanding Git Commits and GitHub
This section delves deeper into the Git process, explaining the use of 'git add .' to stage all changes before committing them with 'git commit -m'. The importance of commit messages for tracking changes is reiterated. The tutorial then introduces GitHub as a platform for sharing and collaborating on code, detailing the process of creating a repository and linking it to a local project folder using 'git remote add origin'. The concept of pushing commits to GitHub is covered, allowing others to access and review the code, as well as the ability to track the history of changes made.
🛠️ Exploring Branches and Collaborative Workflows
The speaker discusses the concept of branches in Git, likening them to separate game saves that allow developers to experiment without affecting the main codebase. They demonstrate how to create a new branch with 'git checkout -b', make changes, and commit them to this branch. The tutorial also covers merging branches back into the master branch using 'git merge' and the process of pushing branches to GitHub, where others can review and suggest changes through pull requests. The importance of keeping local repositories in sync with GitHub is highlighted, using 'git pull' to update local copies with remote changes.
🔄 Syncing Local Repositories with GitHub and Final Thoughts
This final paragraph focuses on the importance of keeping local repositories synchronized with GitHub to avoid discrepancies between the two. The speaker explains how to pull changes from GitHub to the local machine using 'git pull origin master' and emphasizes the simplicity of the basic Git commands needed for most tasks. They touch on advanced topics like rebasing but decide to save it for a future tutorial. The speaker also addresses the social aspect of GitHub, warning against focusing solely on 'green squares' as a measure of productivity, and encourages viewers to make meaningful contributions instead. The video concludes with a promise of a summary of commands on a black screen for easy reference.
Mindmap
Keywords
💡Git
💡GitHub
💡Git Bash
💡Repository
💡Commit
💡Staging Area
💡Branch
💡Merge
💡Pull Request
💡Push
💡Pull
Highlights
Git and GitHub are two different things, with Git being a software for version control and GitHub being a platform for collaboration.
Git is pre-installed on Mac or Linux computers, while Windows users need to download Git Bash.
Git is essential for programming as it acts like a 'memory card' for saving code progress locally.
Git commands include 'git init' to start a new repository, 'git add' to stage changes, and 'git commit' to save them with a message.
The 'git log' command allows you to view the history of saved changes with their respective dates and commit messages.
GitHub serves as a remote platform to store and share code, enabling collaboration among developers worldwide.
Creating a repository on GitHub involves setting up a new folder and following the instructions to link it with your local project.
Pushing changes to GitHub with 'git push' allows others to access and collaborate on your project.
Branches in Git allow developers to work on different features or experiments without affecting the main codebase.
Merging branches combines changes from one branch into another, typically from a feature branch to the master branch.
Pull requests on GitHub enable developers to submit changes for review and potential merging into the main project.
Keeping your local repository in sync with GitHub is crucial for collaborative projects to avoid conflicts.
Git rebase is a more advanced topic that was not covered in this tutorial but may be addressed in a future video.
The video emphasizes the simplicity of Git and GitHub, aiming to demystify common misconceptions about their complexity.
The presenter uses an analogy of a 'time machine' to explain the concept of reverting to previous commits in Git.
The tutorial concludes with advice on focusing on meaningful contributions rather than superficial GitHub 'green squares'.
A black screen with a summary of Git commands is provided at the end of the video for easy reference.
Transcripts
every resource about git or github
if you look up a git tutorial they over
complicate it
and i've always said this you might not
like this if you're super analytical and
you want me to talk
like a scientist but the best way for
you to understand me
is if i talk to you like you're an idiot
and when i was in college that's exactly
what i wanted for my professors
teach me like i'm a five-year-old
because that's how i think
so i'm gonna break down get instead of
you going and watching the
six part tutorial or paying or whatever
it's really very simple if i teach you
it
in hey i'm gonna teach you like
you are a child and you are my children
and if you're my new child meaning
you're just born
then hit subscribe and like the video
alright so this is unscripted but first
thing i'm going to say
get this out there git and github
are two different things i'm going to
talk about both of them in this video
but i'm going to start with git so let's
begin
what is git well
git is a software that comes with your
computer
and installed on your computer if you
have mac or linux
so if you have a macbook or an apple
computer you have git already
or linux computer you have you already
have git if you have windows
you have to download it so you're gonna
have to download something called git
bash you go to the website you download
it and then it's like a little terminal
window use that is git something you
need
to know yes git is something you need to
know you are not going to be
successful at programming without
knowing git everyone needs to know it
it's like one of the most basic things
it's like terminal you need to know term
you need to know a command line
you need to know git and then you need
to know how to code okay
so what is git do why do i need to know
it here we go
this is as simple as it gets simple as
it gets get
is a memory card for code
if you have a project with a bunch of
files
html css javascript
whatever programming language you want
you want just like how you have a video
game
you want to save your progress as you go
that way if you die you don't lose
all of your progress so with git
every so often you're going to enter a
command
to save your progress now this is
locally on your computer
nobody else can access this you have
this on your computer
so i'm going to go through an example
now i'm going to create a folder
get video i'm going to go into my git
video and then i'm going to make an
index.html file and an app.css file
so i made a folder and i made an html
file
and a css file now if one of these files
gets deleted
i didn't save my progress it's gone
forever
i don't know what was in the file if i
wrote a bunch of html or css
one of the files gets deleted poof oh
well
i can't do anything about that it's gone
forever but if i use
get and i save that i made these files
i could save them with the contents of
the files
and when one gets deleted i can go back
to my saved progress now to use git
you have to know a few commands there's
only a few
and it's not that hard to understand the
first one
is initializing your
folder or project with git
to do that you have to have get
downloaded and then you type
get init initialized empty git
repository
great so that's the same thing as you're
putting a memory card
into your game system because you
obviously can't save the game without
memory
so here we go now we can use git we want
to
save our progress how do we do that well
git add is what you want to save
we can save all of our progress
meaning all of our changes since the
last time we saved
or we could just save a very specific
thing
so after git add you want to put
either maybe a file that you want to
save
so i could just save index.html
but if app.css gets deleted it's gone
forever but i could just save
any changes i've made to index.html
or i can save everything so
git add space period would save
everything
that i've done since the last time i
saved i almost
never commit a specific file i
usually push changes on everything
so in 95 cases
you are going to use git add period and
commit
all of the changes that you've made okay
so now i've said what changes i'm saving
which i chose to save everything now if
we were to get technical
i have added all files to the staging
area
but that might just confuse you so don't
even think about that i've added the
files i want to commit i've added
everything
i am going to save everything now git
commit
actually commits those changes to memory
so you type git commit and then you need
to do
dash m for a message
dash m and describe the changes
describe the save this way when we look
back if we want to go back to this save
progress we know what we're going back
to so you make the message
about what you're saving makes sense so
i'm going to say add
html and css file
two files changed you see that i created
two files
it got saved that progress got saved
now if i delete my html file
and i add a
javascript file well now i've made some
more changes
and i could save my game again so now we
only have
app.js and app.css so let's do it again
save all my changes git commit dash m
delete html and add js
so i've saved my progress twice now
what we've gone over so far is how to
add the files you want to save
and then commit with the message to
you know save the progress of the
message
and get in it to you know start it up
now
if we type git log we can look
at our saved the times we saved
look at this so this is the first time
we saved
it it's a log get log it's a log of all
of your
saved changes add html and css
just gives you the time gives you the
date fantastic and then it gives you
this little hash code used to go back to
it
and then look at this there's our second
one time and date
with the hash code now if i want to go
back
to my previous progress with the html
and the css
where we saved i can copy this
like hash code thingy majig
and then look at this get checkout to
check out that commit
let's see where we're at
oh we're back to our
first saved progress
now here's the tricky part is that when
we go back in time
we're in a different branch
so so now timelines
are getting messed up and we're in a
time machine oh god dude maybe
maybe i shouldn't go with the time
machine analogy
i want to keep this i want to keep this
organized and i don't want to
give too much to you to confuse you now
what is github
now what is git hub well github
is a website
and it's the same thing as bitbucket and
it's the same thing as git lab
they are websites where i just
put the stuff that's on my computer all
my saved progress is on my computer
and i put it all on the internet
so that other people can download my
code
and then go through all my saved
progress they could go back and forth
they could jump through time loops and
go back to my save progress and look
through all my code
and do whatever the hell they want to do
so how do you get your code onto github
well you make a github
profile and then you make a repository
repository means folder
folder means repository same thing so
you're on your thing you go to
repositories on your profile
you hit new you hit new repository you
type the name of it
mine was get video description you could
have a public or private whatever
so now once you do that it gives you
instructions
to hook this up to your folder on your
computer
my folder is on my computer i want it on
the website
it tells me how to do that it gives you
specific instructions
it says get remote add origin
this is a command to just hook it up to
the website
so let's just do that alright ready boom
okay i added the origin
and now this is called a push so you
have your saved
commits you save progress and then you
push it you push to the website
okay and now we go to the website
and there is our code people ladies and
gentlemen
there is our code the css the js
and then the two commits that we can
look through
here's the first one with the html css
here's the second one now someone else
can go to my profile and see this and
they can download it onto theirs
and that's why github is something you
have to know
so you can work with others on projects
from different areas in the world
because whenever i save my progress i
push it up to github
and whenever they want to see what i'm
doing they go to my github
and they can just pull my code down or
they can just look at it on my profile
now do i want to go into branches right
now no
i don't this video's already been long
enough but i will
now there's these things called branches
so the by default all the code is on
a master branch don't overthink this
i know you're overthinking that that
just means that's regular
that's just regular that's just you
coding you're saving your changes they
get saved to the master memory
but someone can go off like in a video
game they
could trail off your game and then
you know when you play a video game and
then you do something and it's on your
friend's account
but you don't want to save onto their
account because they still might want to
play what you just did
so you save it into a new file so that's
a different branch
someone could download my code make
changes
and they do it on a different branch so
if we go back to our folder
and i type git checkout dash b that's
going to make a new
branch and i'm going to call it new
branch you put the name of the branch
you want to make
so now i have a new branch open and
there's a master one still but now i
have new branch and i can
make changes and it won't affect
the main game saving the main code
getting saved
it will just be my own branch trailing
off of that code
so i'm going to add a python file
app.pi and i'm going to
commit i'm going to do git add
everything add all my changes
git commit add python file
and now if i do a git log you can see i
got my three commits
and this but this is for my new branch
i'm on new branch here but this stuff is
from
master now the cool part about branches
is that i can merge my
changes on new branch into master if i
want to
or i cannot do that if i don't want to
so if i want to merge all of if i change
like 50 things on my new branch
i can push them all into the main one if
i feel like it
and if i don't want to then fine i don't
i could delete the branch i could do
whatever i want it's
irrelevant until it goes into master so
the point of branches
is so that other people can download
your project
they can go and make changes on a
separate branch
and then they could come to you and be
like dude i made all these changes i
didn't want to mess up what you were
doing
but hey look at these if you like them
merge them into what you are doing
and then i can so what they would do on
github
is they would say hey let's push origin
new branch you could push the new branch
up to github
oh look at that there's two branches on
github now one of them is new branch
one of them is master so if someone
wanted to say hey dude check out my
progress
they could do what's called a poll
request
and whoever owns the repository is gonna
get that and look it over and say hey
these are good or not
so you could say hey dude i changed
some stuff check it out and then you
create it
and then whoever owns the project might
be like oh this guy wanted to change
some stuff
let's see what he changed oh they looked
he added a python file maybe i want that
so that looks pretty good good job dude
you made some good changes
and then you merge it into the master
and then you confirm the merge
and look at that dude now it's merged
into the master
and you know dude it's got the the
commits
from the new branch they got pulled into
the freaking
master branch so now everything is in
the main area
because the guy liked the new branch now
one thing that's important is you always
want your local computer
synced up to github you want these
connected
because it could get out of whack you
need these to be at the same spot
so when there's changes on github that
you don't have on your computer
you want to pull those changes down
to your computer you push when you have
changes that github doesn't have
you push them up to github when github
has changes that you don't have
you pull them down from github
so i will do git pull origin master
and now i pulled down those changes that
python
merging that went on up there i got them
now on my computer
and we could check that out we got the
merge we got the python file
and everything is now on our local
computer now for rebasing
i do need to get a little more technical
with this
and i think i might make a future video
specifically about get rebase
but these are the basics and you can
probably get by
on just these and maybe pick up rebasing
on your own
i don't want to over complicate or make
you overthink
these are the basics this is all you
need to get started using git
and github you don't even need to get
into branches really because you might
not even be working with those right now
just pushing your code up pulling your
code down
making the changes the save changes
when there's stuff on the github that
you don't have
pull it when there's stuff on your
computer github doesn't have
push it you do not need github to use
git
and you you probably do need to get to
use github but
you don't need a github if you just want
to save your changes
but you need a github probably when you
want to collaborate with other people
in different places and you'll probably
need it for like every project
ever now some parting words about github
that you might be interested in
people will judge me because i don't
have all these green squares
so if you want to set up some kind of
auto commit
thing you get a green square if you push
code to github every day
so people like to code every day and
have all these squares look green
and sometimes they don't push anything
useful
they might specifically change or add a
comment
just so that they have a green square on
github
these are people called clout chasers
specifically github clout chasers and uh
they don't
make impactful contributions to projects
and they specifically want green squares
to flex on other developers
you can be one of them or you can let it
go
and just move through and
actually you know do real things with
your life
so that is it for this video i hope i
made this very easy for you to
understand
and i'm going to put a black screen at
the end
with all the commands we went over and
there's only a few
and it's pretty straightforward so that
is why this video is the best get
tutorial out there
please like and subscribe to show me
support
thanks for watching and i'll see you in
the next video
video bye
you
Weitere ähnliche Videos ansehen
Git and GitHub - 0 Experience to Professional in 1 Tutorial (Part 1)
Day-9 | Git and GitHub | What is GIT ? | What is Version Control ? | #devops #2023 #github #gitlab
13 Advanced (but useful) Git Techniques and Shortcuts
What is Git and Github?
Day-11 | Git Interview Q&A and Commands for DevOps | Real World Example |#devops #github #git #2023
【Git入門講座 合併版】この動画1本でGitとGitHubの基礎をゼロからマスター!【初心者向け】
5.0 / 5 (0 votes)