0% found this document useful (0 votes)
67 views19 pages

Git & Github Basics: Digital Media I

Git is a version control system that lets you track changes to files over time. GitHub is an online hosting service for Git repositories that also allows for collaboration. With branches in Git, you can create copies of files to work on without affecting the original. To pull in Git means to clone a remote repository's current state into your local computer.

Uploaded by

Samuel Kpakima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views19 pages

Git & Github Basics: Digital Media I

Git is a version control system that lets you track changes to files over time. GitHub is an online hosting service for Git repositories that also allows for collaboration. With branches in Git, you can create copies of files to work on without affecting the original. To pull in Git means to clone a remote repository's current state into your local computer.

Uploaded by

Samuel Kpakima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

GIT & GITHUB

Basics
Digital Media I
Objectives

01 Understand the terms 03 Create GitHub Account


Git and GitHub

02 Download and Install 04 Understand Basic Git


Git Command
WHAT IS GIT?
Let's brainstorm
What is Git?
Git is a version control system which let’s you track
changes you make to your files over time.

You can also make a copy of your file;


With Git, you can revert to
make changes to that copy, and then
various states of your
merge these changes to the original
files.
copy.
How to Install Git
In order to use Git, you have to install
it on your computer.

git --version
Download the latest version of Git on the
official website.
https://git-scm.com/downloads

After installation, verify that your git is


installed by typing “git - -version” in
your command line.
How to Configure Git
In the command line, set your username

git config - -global user.name “Your-Username”

In the command line, set your email

git config - -global user.email “Your-Email”

Note: Just make sure to replace "YOUR_USERNAME" and


"YOUR_EMAIL" with the values you choose.
How to create and Initialize a Project in Git

Using Command Line Using VS Code Editor


Using the command line
Open your new folder in
navigate to your new folder
the editor
Cd “parent folder”
Open a new terminal for
your project
Cd “Art277” Create a folder on
your computer To initialize your project,
“Art277” simply run git init
WHAT IS
GITHUB?
Let's brainstorm
What is Github?

GitHub is an online hosting service for Git


repositories.

GitHub let’s you store your repositories on their


platform.

Another awesome feature that comes with GitHub


is the ability to collaborate with other developers
from any location.
How to push a repository to GitHub
We push a GitHub repository by following three (3) simple steps.

01 Create a GitHub account


To be able to use GitHub, you will have to create an account first.
You can do that on their website.

Create a repository
02 You can click on the + symbol on the top right corner of the page
then choose "New repository". Give your repo a name then scroll
down and click on "Create repository".

Add and commit file(s)


03 Before we "add" and "commit" our files, you need to understand
the stages of a file being tracked by Git.
Stages of a file being tracked by Git

Committed state Modified state


A file is in the committed state when all A file in the modified state has some
the changes made to the file have been changes made to it but it's not yet saved.
saved in the local repo. This means that the state of the file has
been altered from its previous state in the
committed state.
Staged state
A file in the staged state means it is
ready to be committed. In this state, all
necessary changes have been made so
the next step is to move the file to the
commit state.
How to add files in Git
When we first initialized our project, the file was not being
tracked by Git. To do that, we use this command git add . The
period or dot that comes after add means all the files that exist in
the repository.
Now our file is in the staged state. You will not get a response
after this command, but to know what state your file is in, you
can run the git status command.
How to commit files in Git
To commit our file, we use the git commit -m
"first commit" command.

NOTE: The first part of the command git commit tells


Git that all the files staged are ready to be committed
so it is time to take a snapshot. The second part -m
"first commit" is the commit message. -m is shorthand
for message while the text inside the parenthesis is
the commit message.
Push the repository to GitHub
After you create the repo, you should be redirected to a
page that tells you how to create a repo locally or push an
existing one.

The first command git remote add origin creates a


connection between your local repo and the remote repo on
Github.
The second command git branch -M main changes your
main branch's name to "main".
The last command git push -u origin main pushes your repo
from your local device to GitHub. After adding the new task,
run the git status command.
How to Use Branches in Git
With branches, you can create a copy of a file you would like
to work on without messing up the original copy.

You can either merge these changes to the original copy or


just let the branch remain independent.

To create a new branch, run this command: git checkout -b


test. Replace test with your branch name..
Note: checkout tells Git it is supposed to switch to a new branch. -b tells Git to create a
new branch. test is the name of the branch to be created and switched to.

To merge the new state to the main branch, you have to first
stage and commit this branch.
After committing your test branch, switch back to the main
branch by running this command: git checkout main.
How to Use Branches in Git Cont.
Did you notice that we did not add -b ? This is because we
are not creating a new branch but rather switching to an
existing one.

You can check all the branches that exist in your repo by
running the git branch command.

Now we can merge the changes we


made in the test branch into the main
branch by running git merge test. At
this point, you will see all the changes
made in the test branch reflected on
the main branch.
How to Pull a Repository in Git
To pull in Git means to clone a remote repository's current state
01 into your computer/repository.

To test this, just run cd . . to leave the current directory and go


02 back one step to your parent folder.

Go to GitHub, and on your repository's main page you should


03 see a green button that says "Code". When you click on the
button, you should see some options in a dropdown menu. Go
on and copy the HTTPS URL.

After that, run git clone YOUR_HTTPS_URL. This command pulls


04
the remote repository into your local computer in a folder called
Art277.
Summary

Git is a version control With branches, you can


system which let’s you create a copy of a file you
track changes you make would like to work on without
to your files over time. messing up the original copy.

GitHub is an online To pull in Git means to clone


a remote repository's current
hosting service for Git state into your
repositories. computer/repository.
Thank
You
ANY QUESTIONS?

You might also like