Sign the Guestbook
Overview
Learn the basics of the command line, Git, and version control by signing the Guestbook.
Requirements
- A good text editor of your choice
- We like Notepad++ and Visual Studio Code
Steps
Create a GitHub account
- Visit https://github.com/
Setup your email address on GitHub
- Go to
Profile Icon > Settings > Emails > Add email address
and setup your email address - Verify your email address
- In
Primary email address
select the email address you just verified - Select
Keep my email address private
and copy the provided public profile email address, which looks similarly to12345678+USERNAME@users.noreply.github.com
- Go to
Download and install Git
- Visit https://git-scm.com/
- Download and install the latest source release for your operating system with the default installation options (recommended)
- Windows
- Download and install the latest source release
- Mac
- Install Homebrew if needed from https://brew.sh/
- In Terminal, run
brew install git
- Debian/Ubuntu
- In a terminal, run
apt-get install git
- In a terminal, run
- Other
- Please refer to the Git website
On Windows, run the newly installed
Git Bash
app; elsewhere, Git should be ready to go in a terminal: open a terminal- Git Bash offers a way to use Git through the command line with a terminal
- The command line is often accessed through a terminal
- The command line is generally faster to use than a GUI (graphic user interface)
Check the version of Git
- Type
git --version
into the terminal, the output looks similarly togit version 2.30.1.windows.1
- If you do not get a similar message, try reinstalling Git
- Type
Check the current working directory of the terminal
Type
pwd
and you will see the current working directory that your terminal is pointing to, for example on Windows this looks similarly tokashi@Zarya MINGW64 ~ $ pwd /c/Users/kashi
- On Windows
kashi@Zarya
is theaccount-name@computer-name
of the current user on your computerMINGW64
is the Windows port of the GCC C compiler used to build Git and Bash- Bash is a shell, or a command line interpreter written in C
- The authors of Git Bash probably did not bother to rename the build and thus the compiler named it after itself
~
represents the current user’s home directory$
signifies that the terminal is ready to accept your inputpwd
is a command to print (to the terminal) the current working directory (the current folder that the terminal is pointing to)
Create a folder for this project
- On Windows, we recommend
/c/Users/USERNAME/GitHub
USERNAME
is the name of your home folder- Generally, terminals will begin right at your home folder
GitHub
is the new project folder that we will create
- Type
mkdir GitHub
mkdir
is a command to make a directory (a folder) in the current working directory
- Type
ls -lrt
ls
is a command to list files in the current directory-l
is the parameter for listing more detail-r
is the parameter for reversing the sort order-t
is the parameter for sorting by time last modified- A list of directories and files will show up, with the most recently modified entry at the bottom; this should be the new folder
GitHub
and looks similarly tokashinoga@Zarya:~$ ls -lrt total 4 drwxr-xr-x 4 kashinoga stevie 4096 Mar 6 09:25 github
- On Windows, we recommend
Change to the
GitHub
directory- Type
cd GitHub
cd
is a command for changing to a directory- Once the directory is changed, the terminal looks similarly to
kashi@Zarya MINGW64 ~/GitHub $
- Type
ls
, you should seetotal 0
, indicating that the directory is empty
- Type
Setup your global Git username
- This associates commits (changes) with an identity and applies to all repositories (projects from Git)
- Prepare, paste, and enter the following
git config user.name "USERNAME"
USERNAME
can be anything, though it might help to set it as your GitHub username
Setup your global Git email
- This lets GitHub associate commits to your GitHub account, allowing for easier collaboration
- We recommend using the GitHub provided public profile email address we setup earlier
- In the terminal, prepare (replace
YOUR_GITHUB_PUBLIC_EMAIL
), paste, and enter the followinggit config --global user.email "YOUR_GITHUB_PUBLIC_EMAIL@github.com"
Verify that your username and email are correct by pasting each into the terminal
git config --global user.name
git config --global user.email
Fork the Hello, Comma website GitHub repository
- In a browser, go to https://github.com/Kashinoga/hello-comma-website
- Click on the Fork button
- This should create and redirect you to a new repository that now belongs to you, named
USERNAME
/hello-comma-website
- This should create and redirect you to a new repository that now belongs to you, named
- Copy the repository URL
- Click on the green button (labeled “Code”)
- Copy the URL (HTTPS is usually the default selection)
- In the terminal, copy, paste, and enter the following
git clone https://github.com/Kashinoga/hello-comma-website.git
- During and after the cloning, the output looks similarly to
kashi@Zarya MINGW64 ~/GitHub $ git clone https://github.com/Kashinoga/hello-comma-website.git Cloning into 'hello-comma-website'... remote: Enumerating objects: 366, done. remote: Counting objects: 100% (366/366), done. remote: Compressing objects: 100% (232/232), done. remote: Total 366 (delta 156), reused 300 (delta 93), pack-reused 0 Receiving objects: 100% (366/366), 87.39 KiB | 1.43 MiB/s, done. Resolving deltas: 100% (156/156), done.
- This creates a new directory called
hello-comma-website
in yourGitHub
directory
- This creates a new directory called
Change to the
hello-comma-website
directory- Type
cd hello-comma-website
- Type
Add an
upstream
repository- In a terminal, copy, paste, and enter the following
git remote add upstream https://github.com/Kashinoga/hello-comma-website.git
- This adds a new
upstream
repository, which points to the original repository - This allows you to sync your local, forked repository with the remote, original one
Check the repository’s upstream repositories
- Type
git remote -v
and get output that looks similarly to$ git remote -v origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch) origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push) upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch) upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
- Type
In your text editor, navigate to the project folder and open it
- The path is generally
~/GitHub/hello-comma-website/
- The path is generally
Navigate to the Guestbook project directory
- The path is
hello-comma-website/content/about/guestbook
- The path is
Open up the Guestbook
Markdown
file:- File
guestbook.md
- Markdown is a language for creating formatted text; in fact, this guide is written in Markdown
- File
You can ignore most of the file for now, instead focusing on the list of names towards the bottom of the file, which looks similarly to
--- widget: blank headless: true weight: 2 title: Guestbook subtitle: Leave your mark. design: columns: 2 --- - Andrew Nguyen - Kashinoga - Stevie Traveler # You will add a new entry here
- Generally, a
#
preceeding a line indicates acomment
Comments
in code are often ignored and only serve to help the developer
- Generally, a
With a hyphen, add your signature as a new line, which then looks similarly to
--- widget: blank headless: true weight: 2 title: Guestbook subtitle: Leave your mark. design: columns: 2 --- - Andrew Nguyen - Kashinoga - Stevie Traveler - Elizabeth "ChessMaster48" Harmon: "Let's play." # Your new entry
Save the file
Get the status of your local repository
In a terminal, type
git status
and get output similarly tokashinoga@Zarya:~/github/hello-comma-website$ git status On branch main Your branch is up to date with 'origin/main'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: content/about/guestbook/guestbook.md no changes added to commit (use "git add" and/or "git commit -a")
Stage your changes to prepare for committing and pushing
- Type
git add .
- This adds all items listed under
Changes not staged for commit:
to the staging area Staged changes
are changes ready to becommitted
- Commits are saved changes ready to be
pushed
- A
push
is saving and uploading commits to the remote repository, allowing others to view the changes
- This adds all items listed under
- Type
Check the status again
Type
git status
and get output similarly tokashinoga@Zarya:~/github/hello-comma-website$ git status On branch main Your branch is up to date with 'origin/main'. Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: content/kb/Git/guestbook.md
- Git now lists all staged changes known as
Changes to be comitted
- Git now lists all staged changes known as
Track your change by adding a message to it
- Type
git commit -m "YOUR_MESSAGE_HERE"
and replaceYOUR_MESSAGE_HERE
with a succinct summary of the changes madekashinoga@Zarya:~/github/hello-comma-website$ git commit -m "Git commit demo" [main c84117b] Git commit demo 1 file changed, 29 insertions(+)
- Type
git log -1
to show the last commit message Commit messages
allow you and others to keep track of changes
- Type
- Type
Push your changes to your remote repository
- Type
git push origin
and get output similarly tokashinoga@Zarya:~/github/hello-comma-website$ git push origin Enumerating objects: 17, done. Counting objects: 100% (17/17), done. Delta compression using up to 12 threads Compressing objects: 100% (12/12), done. Writing objects: 100% (12/12), 1.87 KiB | 1.87 MiB/s, done. Total 12 (delta 10), reused 0 (delta 0) remote: Resolving deltas: 100% (10/10), completed with 5 local objects. To https://github.com/Kashinoga/hello-comma-website.git 7ce3c02..541ec43 main -> main
- This saves your changes remotely
- Type
Check your changes on GitHub
Create a
pull request
- On GitHub, navigate to your project directory
- Click on
Pull request
- The default branches displayed should be correct to allow you to request to merge your changes to the original repository
base repository: kashinoga/hello-comma-website
base: main
head repository: USERNAME/hello-comma-website
compare: main
- Enter a title and description for your pull request
- Use the
Create Pull Request
button to submit or save a draft
That’s it! We will review your pull request and then accept it as applicable.
Treat yourself!