GitHub and Git: A Guide
GitHub and Git: A Guide
{ }
DQG
*LW
$*8,'(>
Part of
Learn and Apply
A quality, accessible, and free education facilitates economic
mobility and positive change to our world
1
Identifiers
Authors and course developers:
Eng. Ridha Dridi
Mrs. Fathia Jelassi Ep Dridi
Aziz Dridi
Salim Dridi
Title:
GitHub and Git: A Guide / The Dridi Foundation
Series:
Learn and Apply series
Includes references
2
About Learn and Apply, an
Education Project by The
Dridi Foundation
Learn and Apply is a concise, accessible, and free multilingual
education platform providing video courses, books, and audiobooks on
different topics. It's the first education platform to use Artificial
Intelligence to translate books and produce audio for the courses. The
courses demonstrate the books.
The French and Arabic versions were produced by Eng. Ridha Dridi,
Aziz Dridi, and Salim Dridi.
Third Pillar is a web and mobile app for Muslims to help them calculate
and pay their obligatory alms, Zakat. Zakat is the third of the five pillars
of Islam.
3
ThirdPillar.net
The Dridi and Jelassi families are from Tunisia. To help improve the
economic conditions of Tunisia and provide opportunities, The
foundation submitted funding applications to USAID, USADF, and other
public and private organizations to finance the production of renewable
energy. Increasing Tunisia's generation of solar power was suggested.
4
The Foundation’s
Commitment to Equality,
Diversity, and Inclusion
The Dridi Foundation acknowledges the diversity of the readers in their
different identities, backgrounds, and views, and the content is created
free from bias toward these aspects.
The Foundation is dedicated to creating educational content in different
languages.
Visual learning differences were considered when creating the material,
and accessible versions of the books are available.
5
Legal Information
Learn and Apply is an education project produced by The Dridi
Foundation.
E-Mail: contact@dridi.org
Phone: +1 607-216-7767
Fax: +1 607-360-6587
GitHub and Git: A Guide is published in compliance with the laws of the
United States of America and placed in the public domain in its entirety
under the terms of the Creative Commons Zero (CC0) license. The
materials presented are freely available for any use without attribution
or restriction.
In addition to the logos of GitHub and Git, this book may contain other
images, logos, and names that are trademarked.
The use of trade names, trademarks, service marks, and similar terms
in this publication is not to be taken as an expression of opinion as to
whether they are subject to proprietary rights.
The guidance and data presented in this book are deemed reliable and
correct. Despite this, The Dridi Foundation and the authors are not liable
for errors or omissions and make no warranty express or implied,
concerning the material contained.
7
Chapter 1
Fundamentals
Outline
After a short introduction to the book and its video course, the
fundamentals chapter begins with installing and setting up the
necessary programs and accounts, then discusses the basics of Git,
including its three stages: the working directory, staging area, and
repository and its components: branches, commits, tags, trees, blobs,
and references. It also provides an overview of common git commands
and concludes with a couple of advanced techniques: combining
commits using squashing and saving changes temporarily using
stashing and worktrees.
8
Chapter 1: Fundamentals
Unit 1.1
Introduction
learnapply.org/course/intro
If you’re familiar with GitHub and Git, we recommend you watch the
project example:
learnapply.org/git/demo
The code files are available on GitHub:
github.com/learnapply/git
Below each unit is a link to the corresponding Learn and Apply web
page, which includes the video demonstration.
The Programming series uses Windows as the operating system, but
everything can be replicated on MacOS or Linux.
This book explains most topics related to GitHub and the Git version
control system. It describes many Git commands and details common
use cases and options.
Previous experience isn’t required.
It explains the benefits of using Git to manage code files, such as
branching and history management.
The book covers GitHub starting chapter 3. It enables remote
repositories and provides collaboration features and additional services
such as Actions and Pages.
80 ȱ 9
Chapter 1: Fundamentals
10 ȱ 80
Chapter 1: Fundamentals
Unit 1.2
Installation and setup
learnapply.org/git/1.2
Example Description
Sets Visual Studio Code as
git config --global
the default program for
core.editor "code --
manipulating files with Git
wait"
commands
git config --global Configures the Git
user.name "username" username
git config --global
Configures the Git email
user.email "email"
80 ȱ 11
Chapter 1: Fundamentals
1.2.3 GitHub
To use GitHub, the programmer will need to create an account on
github.com
Once an account has been created, developers need to create a
Personal Access Token (PAT) from their GitHub account's settings.
GitHub discontinued the use of account passwords as an authentication
method inside the command line in 2021. PATs are now used instead.
12 ȱ 80
Chapter 1: Fundamentals
Unit 1.3
The 3 stages of Git
learnapply.org/git/1.3
1.3.3 Repository
A repository, often referred to as 'repo', is a data structure maintained by
Git. It's the folder containing the project's files and subfolders.
Repositories can be either local or remote if the programmer is using
GitHub.
To save the changes they made, the programmer must commit those
changes using git commit. The repository is where changes are saved
after they have been cohmmitted from the staging area.
The repository tracks changes and contains all objects of the commits
and their references. It also stores the metadata of files and folders of
the Git project.
Unit 1.4
The components of Git
learnapply.org/git/1.4
1.4.1 Branches
Creating branches is the equivalent of creating versions of a codebase.
By using branches, programmers can implement new features and fix
risky bugs in isolation from the production branch.
14 ȱ 80
Chapter 1: Fundamentals
Example Description
git branch
Creates a new branch
branch_name
git branch –-
Lists branches containing a
contains
certain commit
commit_hash
git branch -vv Views a branch in more detail
git branch Lists local branches
git branch -d
Deletes the branch
branch_name
Lists both local and remote
git branch –all
branches
git branch - Displays a list of all local
sort=committerdat branches and sort them based
e on the date of their last commit
git branch Shows all the differences
first_branch_name made on the second branch
..second_branch_n since it diverged from the first
ame branch
git checkout
Switches to the named branch
branch_name
80 ȱ 15
Chapter 1: Fundamentals
A best practice is to set different branches for different tasks and not
have too many branches. This helps teams work on a feature in different
ways if they choose to do so.
1.4.2 Commits
Git has 4 types of objects: commits, tags, trees, and blobs.
To save the changes the made, the programmer must save those
changes by committing them using the command
git commit -m "commit_message"
The hashes of the tree and parent commit are metadata and pointers to
other Git objects that contain the actual contents of the commit.
16 ȱ 80
Chapter 1: Fundamentals
Example Description
git cat-file -p View the contents of a
commit_hash commit
git commit -m
Creates a new commit
commit_message
git commit rev-list -- Lists commits in
online branch1 branch2 branch1 and branch2
^branch3 but not in branch3
It shows the previous
git show
commit
Shows the nth commit
git show @~n from the last commit
made
1. git checkout main
2. git add .
3. git commit -m An example of moving
"commit_message" commits from the main
4. git branch branch to a new branch.
branch_name This doesn't affect
5. git reset HEAD~n –- changes already pushed
hard to a GitHub repository.
6. git checkout
branch_name
80 ȱ 17
Chapter 1: Fundamentals
1.4.4 Tags
Tags are references that point to previous points in the history of a Git
project. They resemble version numbers in programs.
Example Description
git tag Creates a tag of the current
tag_name branch
git tag
tag_name Creates a new commit
commit_hash
git tag Lists all created tags
Finds the most recent tag of a
git describe
commit
1.4.5 Trees
Trees represent a folder's structure and its contents.
Although, they're an essential building block in how Git stores and
manages code versions, no common use cases can be accomplished
with them.
1.4.6 Blobs
Blobs hold the raw data of each file in the repository. There are no
common use cases involving them.
80 ȱ 19
Chapter 1: Fundamentals
Sometimes, rather than a single line containing the current branch, the
output of this command will be random text and numbers; in that case,
the HEAD pointer is detached.
This is a situation where the reference is not pointing to any branch and
usually occurs when a programmer creates a new commit without
creating a new branch.
To fix this, either the git checkout or git switch commands are used.
Unit 1.5
Common Git commands and their
options
learnapply.org/git/1.5
To view more detail and information about these commands, follow them
20 ȱ 80
Chapter 1: Fundamentals
git rm -h
git help rm
Always consult the official Git documentation for a full list of command
options, detailed explanations, and the latest changes.
git-scm.com/docs
Example Description
git add . Adds all files to the Staging Area
Adds modifications of files already in
git add -u the Staging Area without the newly
created files in the Working Directory
git add Adds the selected files to the Staging
file1 Area
file3
An interactive view is displayed on the
git add -i command prompt and the programmer
can select which files are added
80 ȱ 21
Chapter 1: Fundamentals
The last use case is the interactive version of adding. It should be used
when dealing with entangled changes in the working directory that a
programmer would like to split into different commits.
It should also be used if the programmer is in the middle of an interactive
rebase and would like to split a too-large commit.
Example Description
git branch
Creates a new branch
branch_name
git branch –-
Lists branches containing a
contains
certain commit
commit_hash
git branch -vv Views a branch in more detail
git branch Lists local branches
git branch -d
Deletes the branch
branch_name
Lists both local and remote
git branch –all
branches
git branch - Displays a list of all local
sort=committerdat branches and sort them based
e on the date of their last commit
git branch Shows all the differences
first_branch_name made on the second branch
22 ȱ 80
Chapter 1: Fundamentals
1.5.6 git mv
git mv renames folders, repositories, and local and remote branches.
It can also be used to move files and folders between different locations.
As an example, to change the location of a file to a new location and
add this move to the staging area, use the command
git mv existing_path new_path
1.5.7 git rm
git rm deletes a file from the project and adds its removal to the staging
area for the next commit.
git rm file_name
Example Description
Shows a list of all commits in
git log
chronological order
git log –- Shows all commit logs with an
stat -M indication of any paths that moved
git log -
Lists the version history of a file,
follow
including its renaming history
file_name
80 ȱ 23
Chapter 1: Fundamentals
The git tag and git describe commands are used to work with tags.
Tags are references that point to previous points in the history of a Git
project. They resemble version numbers in programs.
Example Description
git tag Creates a tag of the current
tag_name branch
git tag
tag_name Creates a new commit
commit_hash
git tag Lists all created tags
Finds the most recent tag of a
git describe
commit
1.5.10 git diff
git diff is used to view the differences between files and branches.
Example Description
Shows the differences between the
git diff staged and unstaged versions of
files
Shows differences between files in
git diff -
the staging area and the latest
staged
working directory version
git diff
Shows differences between two
first_branch
branches
second_branch
git show is used to view expanded details of Git objects (blobs, trees,
tags, and commits).
Table 1 Output of git show when used with different Git objects
Object Output
Shows the log message and other changes
commit
that occurred in the selected commit
Shows the tag message and other tags
tag
included in the tag
Show the names and contents of objects in
tree
a tree
blob Shows the direct content of the blob
Unit 1.6
Combining commits and saving
changes temporarily
learnapply.org/git/1.6
1.6.1 Squashing
This is a method of combining 2 or more commits into 1. It gives a
cleaner commit history and makes it easier to review changes.
Squashing isn't a dedicated Git operation but is rather used when
merging changes from other branches into the main branch of a project.
It can be used as an option with the git merge and git rebase
commands. It can also be used to squash recent commits.
Example Description
1. git reset
–-soft Squash n recent commits without
HEAD~n rebasing
2. git commit
1. git merge –
Squash during a merge. As an
-squash
alternative to the command line,
branch_name
80 ȱ 25
Chapter 1: Fundamentals
1.6.2 Stashing
Stashing is a method of temporarily storing changes made to the
working directory so the programmer can work on something else and
resume work on the changes later.
Example Description
Creates a new stash and saves all
git stash uncommitted changes in the working
directory and staging area
Similar to git stash, but also includes
git stash
untracked files. Untracked files are
push -u
those that were never in a repository
git stash
Creates a new stash and creates a new
branch
branch from it with the specified name
branch_name
git stash
Lists all stashes made
list
git stash Applies changes from the most recent
stash to the working directory but
apply
keeps the stash intact
1.6.3 Worktrees
Worktrees are folders in a Git project where programmers store
changes temporarily. They're an alternative to git stash which
serves the same purpose.
26 ȱ 80
Chapter 1: Fundamentals
Example Description
1. git
worktree add -
b
emergency_fix
../temp master
2. pushd
../temp Make an emergency fix, remove it
3. git commit when d, and then resume the
-a -m earlier code session
commit_message
4. popd
5. rm -rf
../temp
6. git
worktree prune
git worktree Removes information about a
prune worktree
git worktree
Lists existing worktrees
list
80 ȱ 27
Chapter 6: Advanced and Additional Topics
Chapter 2
History
Management and
Undoing Changes
Outline
This chapter covers various Git features, including undoing, recovering,
modifying, and restoring operations. It also discusses branch
management commands such as checkout, switch, and restore, and
introduces another method of viewing commit history using git reflog
rather than git log. The chapter concludes with an explanation of
patches, which capture and allow changes to a code base to be shared,
applied or reviewed.
28 ȱ 80
Chapter 1: Fundamentals
Unit 2.1
Undoing and changing
learnapply.org/git/2.1
Example Description
Undoes the changes of the last
git revert HEAD
commit
git revert
Undoes a certain commit
commit_hash
Example Description
git reset Resets the current branch to the
commit_hash specified commit
git reset –- Resets the current branch to the
hard specified commit and changes the
commit_hash working directory
Resets the current branch to the
git reset @~n state it was in at the previous
commit
1. git reset – Undoes all changes since the last
-soft HEAD~n commit. This doesn't remove the
2. git commit commit from history.
git reset -- Undoes changes added to the
hard Staging Area
Discards uncommitted changes
from the working directory and
git reset --
staging area and resets the current
hard
branch to the identified commit.
commit_hash
Subsequent commits are
discarded
Unstages files added to the
git reset --
staging area
30 ȱ 80
Chapter 1: Fundamentals
After modifying the content with the name and email, run the file
chmod +x ./filter.sh
In a case where the programmer ran git reset @~n, which resets the
current branch to the state it was in n commits ago, was run and the
programmer would like to recover, follow the two steps below.
80 ȱ 31
Chapter 6: Advanced and Additional Topics
Unit 2.2
Understanding checkout, switch,
and restore
learnapply.org/git/2.2
Example Description
git checkout -b Creates a new branch and
branchname switches to it
Creates a new branch
git checkout -b
based on another branch
new_branchname
and switches to the new
other_branchname
branch
Removes all changes
git checkout –-file
made to a certain file
32 ȱ 80
Chapter 1: Fundamentals
Example Description
git switch
Switches to a new branch
branch_name
git switch - Switches to the previous branch
git switch -c Creates a new branch and
new_branchname switches to it
Example Description
80 ȱ 33
Chapter 6: Advanced and Additional Topics
Unit 2.3
Viewing commit history using git
reflog
learnapply.org/git/2.3
Example Description
git reflog Displays the reflogs made in
the local repository
git reflog show Displays the reflog entries for
branch_name the branch
34 ȱ 80
Chapter 1: Fundamentals
Reflog only provides a safety net if the changes were committed to the
local repository. All reflogs have a default expiration of 90 days that can
be extended.
Unit 2.4
Patches
learnapply.org/git/2.4
Example Description
80 ȱ 35
Chapter 6: Advanced and Additional Topics
36 ȱ 80
Chapter 3
GitHub and Merging
Changes
Outline
GitHub and merging changes, covering git commands for managing
remote repositories, integrating changes from different branches and
resolving merge conflicts. It introduces an alternative to merging and
rebasing: the git cherry-pick command. The chapter also details Pull
Requests, a key GitHub feature, explains five common collaboration
workflows, and concludes with a discussion of configuring and using
SSH connections.
80 ȱ 37
Chapter 6: Advanced and Additional Topics
Unit 3.1
Manipulating remote repositories
and merging
learnapply.org/git/3.1
3.1.1 Overview
Figure 2 Overview of Git commands for moving changes
38 ȱ 80
Example Description
git remote -v Lists all currently configured
remote repositories along with
their URLs
git remote add
Links a remote repository to
remote_repo_name
the local repository
url
git remote remove Deletes a remote configuration
remoe_repo_name from the local repository
3.1.3 git clone
git clone creates a local copy of a remote repository using the GitHub
URL of the remote repository. This command allows a person to work
on the code independently and contribute changes back to the original
repository.
Example Description
git clone url Shows the differences between the
staged and unstaged versions of
files
git clone url Clones a Git repository from the
-b branch_name address into the given folder and
directory_path checks-out the given branch
git clone url
-b branch_name
Clones a single branch
--single-
branch
Example Description
80 ȱ 39
Chapter 6: Advanced and Additional Topics
40 ȱ 80
git merge branch_name
3.1.8 Rebasing
Rebasing modifies where a certain number of commits are located. It
can also combine and modify commits and their messages and can also
be used to reorder commits. The interactive version of rebasing opens
an interactive editor in the command line and eases these functions.
git rebase -i
The git diff command gives programmers the ability to see merge
conflicts.
80 ȱ 41
Chapter 6: Advanced and Additional Topics
Example Description
git diff –-
Views merge conflicts against the
base
file in current branch
file_name
git diff –-
Views merge conflicts against
ours
changes made
file_name
git diff –-
Views merge conflicts against
theirs
other changes
file_name
git diff Allows the programmer to visually
compare changes between
different versions of files or
commits within a Git repository
Method Description
git merge –- This command cancels a
abort merge. Use it to undo and
start again
git rebase -- This command cancels a
abort rebase. Use it to undo and
start again
1: git add file1
file2
2: git rebase –
In this method, conflicts
continue
are resolved and added,
or
and then the merge or the
1: git add file1
rebase is resumed.
file2
2: git merge --
continue
42 ȱ 80
Unit 3.2
git cherry-pick
learnapply.org/git/3.2
3.2.1 Overview
Using git cherry-pick programmers can select which commits to
include when integrating changes from one branch to another.
It's also useful for fixing mistakes in previous commits and in applying
changes to multiple branches.
However, it can introduce merge conflicts that must be resolved
manually and can change the commit history of a branch.
3.2.3 Examples
These are examples of 4 use cases involving cherry-picking.
Algorithm 4 First use case: Deliver a bug fix to the end user as fast as
possible
Assumptions:
The production branch is the branch of the program
deployed to the public
The fix was already committed in the feature branch
80 ȱ 43
Chapter 6: Advanced and Additional Topics
1: Identify the commit that contains the fix for the bug
using git log
2: Switch to the production branch using git checkout
3: Use git cherry-pick commit_hash to apply the fix to
the production branch
4: Resolve any conflicts by editing area between right
arrow and left arrow markers in files
5: Push changes to the remote repository using git push
origin HEAD
6: Deploy changes using the development process
Assumptions:
There is a production branch
The fix was already committed in the feature branch
1: Identify the commit with the bug to undo using git log
2: Create a new commit with reversed changes using git
cherry-pick commit_hash
3: Resolve any conflicts by editing area between right
arrow and left arrow markers in files
4: Push changes to the remote repository using git push
origin HEAD
44 ȱ 80
1: Identify the commit or commits containing changes to
apply using git log and note down the commit hash or
hashes
2: Run git cherry-pick commit_hash for each commit
Second method
Unit 3.3
Understanding GitHub Pull
Requests
learnapply.org/git/3.3
3.3.1 Overview
Pull Requests, not to be confused with the git pull command, are
initiated on GitHub, not the command line. When a programmer starts a
Pull Request, they're proposing a set of changes for other team
members to test, review, and provide feedback on.
If the decision to implement the changes is taken, the maintainers of the
repository will merge them. At a minimum, either two distinct branches
or two distinct repositories are needed for a pull request.
A Pull Request has the following components:
The title and description
The commits included in the pull request
A discussion section where programmers can provide feedback
and comments
A visual view of the changes made to the code
46 ȱ 80
Unit 3.4
Workflows
learnapply.org/git/3.4
3.4.1 Overview
A collaboration workflow standardizes the steps programmers in a team
follow to manage and collaborate on code when using Git and GitHub.
It encompasses practices such as branching, merging, code review,
outlining how changes are proposed, and integration of approved
changes into the main codebase.
Using a workflow helps maintain order, efficiency, and improve
collaboration.
The 5 workflows described in this subchapter introduce naming
conventions for branches and the purpose of each branch is pre-
defined.
Branch Description
main The deployable version of the codebase
feature For new features or bug fixes
develop Serves as a staging area for ongoing
development
release Facilitates preparation for production
releases
hotfix To address critical bugs or issues
fork A copy of the main repository created by a
programmer
These workflows are a starting point and teams can create their own
based on the needs and requirements of a project.
80 ȱ 47
Chapter 6: Advanced and Additional Topics
48 ȱ 80
Figure 5 Branches of the Feature Branch workflow
80 ȱ 49
Chapter 6: Advanced and Additional Topics
50 ȱ 80
1: Fork the main repository
2: Clone the fork to the machine
3: Create one or more feature branches for additional
features and fixing bugs
4: Make changes
5: Push the branch with the changes to the remote
repository
6: Create a pull request
7: The pull request is reviewed and tested by the team
8: If it passes the test, the changes in the pull request
are merged
Unit 3.5
Understanding SSH connections
learnapply.org/git/3.5
3.5.1 Overview
This book discussed using URLs within the command line to access
GitHub's services and remote repositories. Secure Shell (SSH) is an
alternative method. SSH uses strong encryption to protect data from
being intercepted and is considered safer than https links.
When setting it up, two keys are created: a public key and a private one.
The public key is shared with the remote server. It's used to verify the
programmer's identity. The private key is kept a secret.
80 ȱ 51
Chapter 6: Advanced and Additional Topics
3.5.3 Examples
Code 30 Examples of SSH in the command line
Example Description
git clone
git@github.com:[GitHub Clone a new repository
username]/[repo using SSH
name].git
git remote set-url
origin Change an existing
git@github.com:[GitHub repository from https to
username]/[repo SSH
name].git
52 ȱ 80
Chapter 4
Cleaning,
Customization,
and Correcting
Errors
Outline
80 ȱ 53
Unit 4.1
Custom abbreviations for Git
commands
learnapply.org/git/4.1
Before After
git config –-alias.ci git ci -m
"commit" "commit_message"
git config –- git unstage
alias.unstage "reset -–"
Unit 4.2
Correcting errors
learnapply.org/git/4.2
1 Ǥϙ͗͏
Chapter 6: Advanced and Additional Topics
Code 34 To check for errors and clean the repository by removing all
unreachable and loose objects
1. git fsck
2. git gc --prune
The session will start, and Git will find where the bug
was introduced
Unit 4.3
Cleaning files and repositories
learnapply.org/git/4.3
git clean removes untracked files and directories from the working
directory.
͗͏ϙǤϙ2
An untracked file or folder is one that is present in the working directory
but isn't part of the local repository, remote repository, or staging area.
Its changes and versions are untracked by Git.
Example Description
git clean -i Cleans files and folders
interactively
git clean -f Removes all untracked files
git clean -fX Cleans ignored files from the
current folder and all subdirectories
git clean -fd Removes all untracked directories
and the files within them
git clean -dn Previews all directories that will be
cleaned
1. git fetch Removes tracking between local
–p and deleted remote branches. The
2. git branch second command will display which
-vv branches are no longer being
tracked. The word "gone" indicates
they're no longer being tracked
Unit 4.4
Disabling Git's tracking
learnapply.org/git/4.4
3 Ǥϙ͗͏
Chapter 6: Advanced and Additional Topics
Example Description
git config –global
Ignores certain files and
core.excludesfile
folders on a global basis
.gitignore_file_path
git rm –-cached Ignores a file that was
file_name already committed to a Git
repository
git update-index -- Ignores subsequent
assume-unchanged changes to a file without
file_name removing it from the
repository
git update-index –-
Ignores changes in tracked
skip-worktree
files
file_name
git status --ignored Finds all files in the current
folder ignored by a global
.gitignore file
git check-ignore Checks if a certain file is
file_name ignored
͗͏ϙǤϙ4
Chapter 5
GitHub Actions
and GitHub Pages
Outline
This chapter describes two GitHub features: Actions and Pages.
1 Ǥϙ͗͏
Chapter 5: GitHub Actions and GitHub Pages
Unit 5.1
Understanding GitHub Actions
learnapply.org/git/5.1
Workflows
Jobs
Steps
Feature Description
Conditions Control job execution based on
triggers. For example, certain
changes in files
Matrices Run jobs with different configurations
simultaneously to test various
scenarios
Concurrency Limits the number of parallel jobs to
manage resource usage efficiently
Environments Different environment variables for
different jobs and steps can be
defined
Containers Run jobs inside containers such as
the ones provided by Docker
Secrets Store sensitive information such as
passwords and PATs
Re-runs For re-running certain jobs or
workflows if needed
͗͏ϙǤϙ2
Chapter 5: GitHub Actions and GitHub Pages
Unit 5.2
Understanding GitHub Pages
learnapply.org/git/5.2
GitHub Pages is a service for static site hosting. Static sites don't
generate pages for programmers in real-time and only use HTML, CSS,
and JavaScript files from a GitHub repository.
GitHub Pages runs those files through the build process and provides
the programmer with a GitHub URL for the website.
If configuring a personal domain instead, the programmer will need to
set up a CNAME record with the domain registrar in the DNS settings.
When editing the CNAME record, the name is the domain bought, and
the value is the URL provided by GitHub Pages.
There are 3 types of GitHub pages:
Project: The websites are connected to a certain project
repository hosted on GitHub
User and Organization: The websites are connected to a
certain GitHub account
3 Ǥϙ͗͏
Chapter 6
Advanced and
Additional Topics
Outline
The Advanced and Additional topics chapter will begin with an overview
of GitHub Desktop, then it will explore hooks, submodules, subtrees and
bundles. It also introduces the git archive command for compressing
different Git items into a ZIP file. The chapter concludes with best
practices to follow when using GitHub and Git, and an explanation of
GitHub's README section.
1 Ǥϙ͗͏
Unit 6.1
GitHub Desktop
learnapply.org/git/6.1
Unit 6.2
Custom hooks
learnapply.org/git/6.2
Similar to GitHub Actions, hooks are scripts that automatically run if a
certain event or action triggers them. Hook files have pre-determined
names that can't be modified. They don't take file extensions and must
be placed inside the .git/hooks subfolder in a Git repository.
Scripts are either server-side or client-side.
1 Ǥϙ͗͏
Chapter 6: Advanced and Additional Topics
Script Description
update Triggered after an update to the
repository
post-commit Executed after a commit is made. It's
usually used to notify the Git
programmers
post- For notifying Git programmers. It's
receive executed after a push is received
pre-commit Triggered before a commit is made
and it's usually for running automated
tests to make sure the commit won't
break the project
pre-commit- Triggered before the commit message
msg editor is opened
pre-rebase Executed before a rebase has started.
Usually used to make sure the rebase
is appropriate
pre-receive Executed before a push is received
Unit 6.3
Submodules and Subtrees
͗͏ϙǤϙ2
learnapply.org/git/6.3
Submodules Subtrees
A submodule acts as a Subtrees embed the entire
link to external contents of another
repositories repository, including its
history, into the main
repository
A submodule keeps the A subtree increases the size
main repository size of the main repository
small as it only stores significantly as it only
the link to external code includes all files and the
history of the subproject
Example Description
git submodule update -- Pulls all
recursive --remote submodules from
their respective
remote
repositories
git submodule add url Adds a new
local_folder_path submodule to the
local repository
1. git submodule deinit -f
--name submodule_name Deletes a
2. rm -rf submodule from
.git/modules/submodule_name the repository
3. git rm -f submodule_name
3 Ǥϙ͗͏
Chapter 6: Advanced and Additional Topics
Unit 6.4
Bundles
learnapply.org/git/6.4
Bundles help programmers transfer repositories to machines that have
no internet connection. They allow the packaging of all Git objects and
references of a repository into a bundle that can be transferred to
another machine via a USB drive for example. Their file extension is
.bundle.
Unit 6.5
Creating archives
learnapply.org/git/6.5
Example Description
git archive --
Creates a ZIP archive of the
format zip HEAD >
current branch
archive-HEAD.zip
͗͏ϙǤϙ4
git archive --
output=archive- Creates a ZIP archive of a
archive_name – certain tag. The name of the
prefix=src- archive and tag must be
directory=name defined
tag_name
git archive --
output=archive- Creates a ZIP archive of a
archive_name – local branch. The name of the
prefix=src- archive and local branch
directory=name must be defined
local_branch_name
git archive --
output=archive- Creates a ZIP archive of a
archive_name – remote branch. The name of
prefix=src- the archive and remote
directory=name branch must be defined
remote_branch_name
Unit 6.6
Best practices and GitHub's
README section
learnapply.org/git/6.6
͗͏ϙǤϙ6
Appendix
Appendix
learnapply.org/course/final
Outline
The book ends with Learn and Apply’s other courses, books, and series.
7 Ǥϙ͗͏
Appendix
Additional resources
Practice makes perfect. Apply the contents of this book to a personal
project and attempt to use GitHub and Git in all future software
development, regardless of programming language.
͗͏ϙǤϙ8
Appendix
github.com/dictcp/awesome-git
Platforms for open-source projects and developer tools:
sourceforge.net
github.com
Discounts are regularly offered for commercial products.
Using their school's email address, students can apply for a price
reduction or free access to various programming tools and benefits
through programs such as the GitHub Developer Pack, or by contacting
the developers directly.
9 Ǥϙ͗͏
Appendix
scholar.google.co
m
An archive for millions of open-
ArXiv
access research papers and
arxiv.org
preprints by Cornell University
ArXiv-Sanity
papers Provides an alternative interface
arxiv-sanity- for ArXiv
lite.com
CatalyzeX Provides code implementations
catalyzex.com for most ArXiv papers
PapersWithCode
A portal for Artificial Intelligence
paperswithcode.c
papers, their code, and datasets
om
IEEE Xplore
ieeexplore.ieee.or
g/Xplore/home.jsp
ACM Digital
Library
dl.acm.org
Science Direct
sciencedirect.com
A list of databases containing
JSTOR research papers on various fields
jstor.org and topics
Scopus
scopus.com
Web of Science
webofscience.co
m/wos
DOAJ
doaj.org
Google Public
Data Visualizes publicly available
google.com/publi datasets
cdata
TensorBoard by
Provides visualizations and tools
TensorFlow
needed for Artificial Intelligence
tensorflow.org/ten
experiments
sorboard
͗͏ϙǤϙ͐͏
Appendix
Connected Papers
Provides a visual graph to see
connectedpapers.
connections between papers
com
Dimensions Visualizes networks of papers to
app.dimensions.ai discover connections between
/auth/base/landing them
Aim An Artificial Intelligence-based
aimstack.io open-source experiment tracker
Phind Artificial Intelligence-based search
phind.com engine and pair programmer
Perplexity.ai
An alternative AI search engine
perplexity.ai
Elicit Analyzes research papers and
elicit.com summarizes them
Data Version An open-source version control
Control system for Data Science and
dvc.org Artificial Intelligence projects
InterviewBit Provides free interview questions
interviewbit.com and their solutions
AlgoExpert A paid resource for interview
algoexpert.io questions and their solutions
MLflow Tracking Provides an API to see detail and
mlflow.org/docs/la visualize the results of Artificial
test/tracking.html Intelligence experiments
Provides a platform to run the
ClearML
entire Artificial Intelligence
clear.ml
lifecycle
DAGsHub An open-source collaboration
dagshub.com platform for Data Science
An Artificial-Intelligence
Krater.ai
application for content creators
krater.ai
and writers
Chat with Open A project that benchmarks the
LLMs accuracy of responses of LLMs to
chat.lmsys.org queries
The book Git Project Management for Developers and DevOps Teams
by Jon Loeliger provides visualizations of concepts and additional
commands and options for Git. It also covers GitLab, another remote
service for Git projects.
11 Ǥϙ͗͏
Appendix
amzn.com/1493222899
The decoder processes each data block and attempts to correct errors
and recover the original data. The amount of data that can be corrected
depends on the characteristics of the Reed-Solomon code.
͗͏ϙǤϙ12
Appendix
These rates refer to the Error Correction Level (ECL) and represent the
maximum percentage of data that can be corrected in case of errors.
For more detail, read the research paper Galois Field in Cryptography
by Christoforus Juan Benvenuto:
sites.math.washington.edu/~morrow/336_12/papers/juan.pdf
References
Atlassian. (n.d.). Git Tutorials and Training | Atlassian Git, Tutorial.
Atlassian from
atlassian.com/git/tutorials
Don, E. (2023). Git prodigy: mastering version control with Git and
Github.
Homebrew from
brew.sh
͗͏ϙǤϙ14
Appendix
sudo
ᶮTo give the current user root access (the equivalent of
'Run as Administrator’ in Windows). This is often used
with commands that require access to the file system.
apt
ᶮTo manage packages on Debian-based Linux systems
snap
ᶮTo manage snap packages
apropos
ᶮTo find all command line commands containing a certain
keyword
man
ᶮTo display the manual page for a certain command line
command
whatis
ᶮTo provide a brief description of a command line command
cd
ᶮTo navigate between folders
ls
ᶮTo list all files and folders located in the current
folder
mkdir
ᶮTo create a new folder inside the current folder
touch
ᶮTo create a new file inside the current folder
15 Ǥϙ͗͏
Appendix
pwd
ᶮTo display the name of the current folder
tail
ᶮTo display the last lines of a file
head
ᶮTo display the first lines of a file
diff
ᶮTo compare the content of 2 files line by line and display
the differences between them
uniq
ᶮTo filter duplicate lines in a file
cmp
ᶮTo test if 2 files are identical or not
comm
ᶮTo compare 2 sorted files and display the lines common
to both
chmod
ᶮTo change the permissions of a file or folder
sudo find
ᶮTo search for files in the system
lsattr
ᶮTo list the properties of a file
͗͏ϙǤϙ16
Appendix
chattr
ᶮTo change the properties of a file
open
ᶮTo open a file located in the current folder
cat
ᶮTo print the contents of a small file in the command line
less
ᶮTo print the contents of a large file in the current
folder
cp
ᶮTo copy and paste files and folders from one folder to
another
rm
ᶮTo delete a file or folder in the current folder
nano
ᶮTo create and open a new file inside the current folder
grep
ᶮTo find text in a file located in the current folder
echo
ᶮTo write text to a file
mv
ᶮTo move or rename files and folders
17 Ǥϙ͗͏
Appendix
history
ᶮTo view all previously executed commands in the current
session of the command line
ping
ᶮTo verify whether a network host is reachable or not
ssh
ᶮTo connect to a remote system
w
ᶮTo display information about the users currently logged
in
uptime
ᶮTo see how long the system has been running
free
ᶮTo display information about the system’s memory usage
du
ᶮTo display the disk space usage of files and folders
df
ᶮTo display information about the disk space usage of the
system
mkfs.ext4
ᶮTo create a new ext4 filesystem on a disk partition or
separate disk
1. sudo mount
2. sudo fsck
3. sudo unmount
͗͏ϙǤϙ18
Appendix
zip
ᶮTo create a zip file
gzip
ᶮTo create a gzip file
unzip
ᶮTo extract a zip file in the current folder
gunzip
ᶮTo extract a gzip file in the current folder
watch
ᶮTo repeatedly run a certain script or command at a fixed
time interval
sleep
ᶮTo introduce a delay before the execution of a script or
command
dd
ᶮTo copy files from one folder to another. This command
can also be used to convert between different file types
rsync
ᶮTo transfer folders between two locations
sync
ᶮTo ensure all pending data is written to storage
19 Ǥϙ͗͏
Appendix
chown
ᶮTo change the file owner or group
chgrp
ᶮTo change the group ownership of a file or folder
env
ᶮTo list environment variables
alias
ᶮTo create shortcuts for commands
whereis
ᶮTo locate the executable and binary files of a command
groupadd
ᶮTo create a user group
members
ᶮTo list members of a group
groupmod
ᶮTo modify the properties of a group
groupdel
ᶮTo delete a user group
usermod
ᶮTo modify the properties of a user
dump
ᶮTo create backups of files or file systems
restore
͗͏ϙǤϙ͑͏
Appendix
source
ᶮTo execute a shell script that’s located in the current
folder
jobs
ᶮTo list all background jobs in the current session
ps
ᶮTo list all running processes
top
ᶮTo see a real-time view of all processes
htop
ᶮTo see an interactive view of all processes
kill
ᶮTo kill the process of a program
kill -9
ᶮTo force kill a program process
killall
ᶮTo kill all processes of a program
clear
ᶮTo clear the command line of anything displayed on it
exit
ᶮTo exit the command line
21 Ǥϙ͗͏
Appendix
Learn and Apply’s platform includes other series such as Finance and
Accounting, Mathematics and Statistics, Sciences, Humanities, and
Languages.
LearnApply.org
͗͏ϙǤϙ22
*LW+XE
EDQG
G*LW
$
$*XLGH
Ś
ɐ
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
3URJUDPPLQJVHULHV
/HDUQDQG$SSO\
/HDUQ$SSO\RUJ