Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Introduction to GitHub

By Adaobi Chuks-Aginam
GitHub: GitHub is a web-based platform for hosting and sharing
code repositories. It provides a range of collaboration features
such as issue tracking, pull requests, and code reviews.
– To use GitHub, you first need to sign up for an account at
www.github.com/signup
GitHub – Once you have a GitHub account, you can create a new
repository to store your code.
– You can create a new repository by clicking the "New" button
on the GitHub homepage on the repositories page.
– You'll need to give your repository a name and choose
whether it should be public or private.
– cd ..: This command allows you to navigate to the parent
directory of your current working directory.
– cd: This command allows you to change your working
Basic directory to a specific directory. You can specify the directory
by providing its absolute or relative path.
commands – ls: This command lists the contents of the current working
directory.
– mkdir: This command creates a new directory with the
specified name in the current working directory.
– touch ‘file-name’: This command creates a new empty file
with the specified name in the current working directory.
– code .: This command opens the current working directory in
the Visual Studio Code editor.
Basic – rm ‘file-or-folder-name’:: This command removes files or
commands directories.
– rmdir ‘folder-name’: This command removes an empty
directory. Note that if the directory is not empty, you will need
to use the "rm" command with the "-r" flag to recursively
remove its contents before you can remove the directory itself.
– Repository: A repository, or "repo" for short, is a collection of
files and directories that are tracked by Git. It can be local,
meaning it is stored on your local computer, or remote,
meaning it is stored on a server such as GitHub.
– git init: This command initializes a new Git repository in the
current directory.
Git basics
– Staging and unstaging: Staging refers to the process of
adding files to the Git index in preparation for a commit. This
is done using the "git add" command, followed by the file or
directory name. To unstage a file that has been added to the
index, you can use the "git reset" command, followed by the
file or directory name.
– Git commit: This command creates a new commit in the Git
repository, recording the changes that have been staged. A
commit includes a commit message, which should briefly
describe the changes that were made. For example, to
commit changes to a file called "index.html", you would use
Git basics the command "git commit -m 'Updated index.html with new
content’”.
– git status: This command displays the current status of your
Git repository. It shows which files have been modified, added,
or deleted since the last commit, and which files are staged or
unstaged for commit.
– Git log: This command shows a list of all the commits that
have been made to the repository. It includes information
such as the commit message, author, date, and unique
identifier (or "hash") for each commit.
Git basics – Git log --oneline: This command shows a more condensed
version of the commit history, displaying only the first seven
characters of each commit's hash and its commit message on
a single line.
Cloning a repository is the process of downloading a copy of
Cloning a the code from a remote repository to your local machine.
– To clone a repository, use the git clone command followed by
repository the URL of the repository you want to clone. e.g. git clone
<repository-link>
Git Branches: A Git branch is a separate line of development
within a Git repository. It allows you to work on different
features or versions of your codebase in parallel, without
affecting the main codebase. Each branch has its own commit
history and can be merged back into the main branch when the
changes are complete.
Git Branch Commands:
– git branch - Lists all of the branches in your repository.
Git branch – git branch <branch> - Creates a new branch called <branch>.
– git checkout <branch> - Switches to the branch called
<branch>.
– git checkout -b <branch> - Creates a new branch called
<branch> and switches to it. git branch -d <branch> - Deletes
the branch called <branch>.
– git branch -m <oldbranch> <newbranch> - Renames the
branch called <oldbranch> to <newbranch>.
Git Merging: Merging is the process of combining two or more
Git branches back into a single branch.
Git merge Git Merging Commands:
– git merge <branch> - Merges the branch called <branch> into
the current branch.
Git Push: Pushing is the process of uploading your local
changes to a remote repository. This makes your changes
available to other developers who are working on the same
project.
Git push Git Push Commands:
– git push - Pushes the local changes to the remote repository.
– git push origin <branch> - Pushes the local changes on the
<branch> branch to the remote repository.
Git Pull: Pulling is the process of downloading changes from a
remote repository to your local repository. This is typically done
when other developers have made changes to the codebase
that you want to integrate into your own local repository.
Git Pull Commands:
Git pull
– git pull - Downloads changes from the remote repository and
merges them into the current branch. git pull <remote>
<branch> - Downloads changes from the <branch> branch of
the <remote> repository and merges them into the current
branch.
– Forking: Forking is the process of creating a copy of a
Forking a repository on GitHub to your own GitHub account. This allows
you to make changes to the code without affecting the original
repository repository. To fork a repository, click the "Fork" button on the
repository's GitHub page.
A README file is a plain text file that contains important
information about a project, such as how to install and use it,
what it does, and who is responsible for maintaining it.
On GitHub, a README file is usually located at the root of the
A good repository and is one of the first things people see when they
README.md visit the repository page.
README files can be written in various formats, such as plain
file text, Markdown, or HTML.
Markdown is a popular format for writing README files on
GitHub as it allows you to format text with headers, lists, links,
and other basic formatting options.
Here are some tips for writing a good README file:
– Provide a clear and concise description of your project,
including what it does and why it's useful. Include examples
and screenshots to help users understand how your project
works. Use simple language and avoid technical jargon as
much as possible. If you need to use technical terms, provide
A good a brief explanation.

README.md – Include step-by-step instructions for how to install and use


your project. Don't assume that users know anything about
file your project or the tools required to run it.
– Provide examples and screenshots to help users understand
what your project does and how it works.
– Organize your README file with headers and bullet points to
make it easy to read and navigate.
RESOURCE GitHub profile: https://github.com/Adaobi-Chuks
README file: https://gist.github.com/Adaobi-
S Chuks/40c9740a55d7ea2cc70b895739a0cd86
THANK YOU

You might also like