Use Git and GitHub as a solo developer
Outcome
Section titled “Outcome”You will turn your semantic HTML project into a Git repository, save two meaningful commits, and push the repository to GitHub. You will finish with a short workflow that you can repeat while building the profile-page project.
Why this matters
Section titled “Why this matters”Git records useful versions of a project on your computer. GitHub stores a connected copy online and gives you a place to inspect and share the repository. A solo developer can use both tools before any teamwork begins.
What you will practice
- Explain the different roles of Git and GitHub.
- Inspect a project with git status and git diff before saving a commit.
- Stage a selected file and create a commit with a specific message.
- Connect a local repository to GitHub and push the main branch.
- Use a repeatable edit, inspect, stage, commit, and push workflow as a solo developer.
What is new and what is reused
Section titled “What is new and what is reused”- New: Repositories, working-tree changes, the staging area, commits, branches, remotes, and pushes.
- Reused: The completed
html-elements/index.htmlpage, the VS Code workspace, using a terminal, saving files, and checking a result before continuing.
Starting point
Before you start
- The completed html-elements folder and index.html file from the semantic HTML lesson.
- VS Code with html-elements open as the workspace root.
- A GitHub account that you can sign in to, or approval to create one.
- Permission to install Git for your Windows account if Git is not already installed.
- Project content that is safe to store in a private online repository.
- Current state
- The semantic HTML page works, but Git does not yet record its versions and GitHub does not have a connected copy.
- First action
- Open a terminal and run git --version. You can use Terminal > New Terminal in VS Code, PowerShell, Command Prompt, or another terminal that can run Git.
- First checkpoint
- The terminal prints a Git version number.
- Help trigger
- Ask for help if Git is unavailable, an installer or sign-in needs administrator approval, the terminal is not inside html-elements, or an authentication prompt does not match this lesson.
Required result
Section titled “Required result”You have completed the lesson when:
html-elementsis a Git repository on a branch namedmain;- Git records
index.htmlin an initial commit; - a second commit records one deliberate footer change;
- the local repository has a remote named
origin; - a private GitHub repository shows both commits on
main; and git statusreports a clean working tree after the final push.
Type Git commands in a terminal
Section titled “Type Git commands in a terminal”Type each Git command in this lesson into a terminal. Do not type the commands into an HTML file, a browser address bar, or the GitHub website. You can use:
- the integrated terminal in VS Code;
- PowerShell;
- Command Prompt (
cmd); or - another terminal where the
gitcommand is available.
This lesson uses the VS Code terminal because it usually opens in the folder that is open as the VS Code workspace. The current folder, also called the working directory, is the folder that the terminal acts on.
The location does not matter when you run git --version or a git config --global command. The --global option saves settings for your Windows account instead of one project.
For every other Git command in this lesson, the terminal must have html-elements as its current folder. This means that html-elements is the folder shown in the VS Code Explorer and that index.html is directly inside it. In VS Code, open the html-elements folder and select Terminal > New Terminal. If you use PowerShell or Command Prompt outside VS Code, use cd to move to the folder first:
cd "C:\path\to\html-elements"dirReplace the example path with the path on your computer. The dir output must list index.html. Keep this project terminal open for the remaining commands. If a command lists files from another project or a parent folder, stop before you stage or commit anything and return to html-elements.
Check Git and your commit identity
Section titled “Check Git and your commit identity”Open your chosen terminal. You can run the next command from any folder.
Run:
git --versionExpected result: The command prints text that starts with git version.
If Windows reports that git is not recognized, download the current installer from the official Git for Windows page. Keep Git Credential Manager selected during installation. Close and reopen VS Code after the installer finishes, then run git --version again.
Git writes an author name and email address into each commit. These values are separate from the GitHub username. Choose a name that you are comfortable showing in repository history.
Sign in at github.com. If you do not have an account, open GitHub sign-up. Create and use your own account. Choose a username that you are comfortable using for development work, use an email address that you can access, and keep your password and sign-in codes private.
GitHub can supply a private noreply email address. Sign in to GitHub, open Settings > Emails, enable email privacy if you want it, and copy the noreply address that GitHub shows. You can also use an email address that is verified on your GitHub account.
On your own Windows account, configure the identity for future repositories. Because these commands use --global, you can run them from any terminal folder:
git config --global user.name "YOUR NAME"git config --global user.email "YOUR EMAIL OR NOREPLY EMAIL"Replace both placeholder values, including the quotation marks around each complete value. Then check the saved values:
git config --global user.namegit config --global user.emailConfirm that git --version prints a version and that both configuration checks print the values you chose.
If it does not work
Section titled “If it does not work”- If
gitremains unavailable after installation, close every VS Code window and reopen thehtml-elementsfolder. - If a configuration check prints nothing, repeat the matching
git configcommand with your value. - If the wrong person’s identity appears on a shared computer, do not create a commit. Ask your teacher to correct the setup first.
Checkpoint: Git and the commit identity are ready
- What now works
- The VS Code terminal can run Git, and Git reports the intended author name and email address.
- Files changed
Git configuration outside the project- What remains
- Initialize the html-elements repository and create its first commit.
- Next action
- Confirm that HTML-ELEMENTS is the VS Code workspace root, then run git init -b main.
- If it does not work
- Run git --version and both git config checks again. Continue only when all three commands return the expected values.
Create the local repository
Section titled “Create the local repository”A repository is a project that Git tracks. The project files remain normal files. Git adds a hidden .git folder that stores the repository history and configuration.
From this point, run each Git command in the project terminal with html-elements as its current folder. Confirm that HTML-ELEMENTS is the top folder in the VS Code Explorer, or that dir lists index.html if you use a separate terminal. Then run:
git init -b maingit statusgit init -b main creates the repository and names its first branch main. A branch is a named line of commits. This lesson uses one branch because the current project and workflow are small.
The first git status output should report:
- the branch name
main; - no commits yet; and
index.htmlas an untracked file.
An untracked file exists in the project folder, but no commit contains it yet.
If it does not work
Section titled “If it does not work”- If Git reports that
-bis an unknown option, update Git for Windows before continuing. - If
git statuslists unrelated folders or many unrelated files, the terminal is in the wrong folder. Do not stage anything. Openhtml-elementsas the VS Code workspace root and open a new terminal. - If Git reports that this is already a repository, run
git status. Continue when the branch and listed files belong tohtml-elements; otherwise, ask for help before changing repository settings.
Stage and commit the completed page
Section titled “Stage and commit the completed page”Git does not commit every saved file automatically. You select the content for the next commit by adding it to the staging area.
Run:
git add index.htmlgit statusgit diff --stagedgit add index.html stages the current saved content of that file. git diff --staged shows the exact content prepared for the next commit.
Read the staged diff. Confirm that it contains the semantic HTML journal and no private information. Then create the commit:
git commit -m "Create semantic HTML journal"git log --onelineA commit is a recorded project snapshot with author information, a time, an identifier, and a message. The log should show one abbreviated identifier followed by Create semantic HTML journal.
Run git status. The result should include On branch main and nothing to commit, working tree clean.
Checkpoint: The local project has its first commit
- What now works
- Git tracks index.html on main, the log shows Create semantic HTML journal, and the working tree is clean.
- Files changed
html-elements/index.html, html-elements/.git/- What remains
- Create an empty private repository on GitHub, connect it as origin, and push main.
- Next action
- Sign in to GitHub and open the New repository page.
- If it does not work
- Run git status. If index.html remains staged, run the git commit command. If it is still untracked, repeat git add index.html first.
Connect the project to GitHub
Section titled “Connect the project to GitHub”Git and GitHub have different roles:
| Tool | Current role |
|---|---|
| Git | Records commits in the local html-elements repository |
| GitHub | Stores a connected remote repository that you access through your GitHub account |
The local repository works without GitHub. Connecting GitHub lets you push committed versions to another location and inspect them in a browser.
Create an empty GitHub repository
Section titled “Create an empty GitHub repository”Open github.com/new and use these settings:
- Owner: Your GitHub account.
- Repository name:
html-elements. - Description: Optional.
- Visibility: Private.
- Initialize this repository with a README: Off.
- Add .gitignore: None.
- Choose a license: None.
Create the repository. Keeping it empty avoids adding a separate history before you push the existing local history.
Add the remote
Section titled “Add the remote”On the new repository page, copy the HTTPS URL. It has this pattern:
https://github.com/YOUR-USERNAME/html-elements.gitIn the project terminal, run the next commands. Replace the complete example URL with the URL that you copied.
git remote add origin https://github.com/YOUR-USERNAME/html-elements.gitgit remote -vA remote is a named connection to another repository. origin is the conventional name for the primary remote. The check should show the same URL for fetch and push.
Push the main branch
Section titled “Push the main branch”Run:
git push -u origin mainThe first HTTPS push can open a Git Credential Manager browser sign-in. Follow the GitHub sign-in and authorization prompts for your account. GitHub does not accept an account password as Git authentication in the terminal. Current Git for Windows includes Git Credential Manager so you can authenticate through the browser instead.
Reload the repository page on GitHub. It should show index.html and the commit message Create semantic HTML journal.
If it does not work
Section titled “If it does not work”remote origin already exists: Rungit remote -v. If the URL is correct, continue to the push. If it is wrong, ask for help before changing it.Repository not found: Compare the URL fromgit remote -vwith the browser address. Confirm the owner and repository name, then confirm that you signed in to the account that owns the repository.- Push rejected because the remote contains work: The GitHub repository was probably initialized with a README,
.gitignore, or license. Do not force the push. Ask your teacher to help you use a new empty repository or combine the histories safely. - Authentication does not open or repeatedly fails: Read GitHub’s Git Credential Manager guidance for Windows or ask for help. Do not paste an account password into the terminal.
Checkpoint: The first commit is on GitHub
- What now works
- The private GitHub repository shows index.html and the Create semantic HTML journal commit on main.
- Files changed
html-elements/index.html, html-elements/.git/- What remains
- Make one deliberate change and repeat the complete solo-development loop.
- Next action
- Return to index.html in VS Code and update the page footer.
- If it does not work
- Run git remote -v and compare its URL with the repository page. Then run git push -u origin main again and read the first error line.
Repeat the solo-development loop
Section titled “Repeat the solo-development loop”In index.html, find the page-level footer and change its paragraph to:
<p>Web learning journal · Level 1 HTML practice</p>Save the file. Then inspect the working tree:
git statusgit diffgit status should list index.html as modified. git diff should show one removed footer line and one added footer line.
Stage and inspect the selected version:
git add index.htmlgit diff --stagedConfirm that the staged diff contains only the intended footer change. Then commit and push it:
git commit -m "Update journal footer"git pushThe first push used -u origin main to connect the local main branch with the remote main branch. Later pushes can use git push while that connection remains in place.
Reload the GitHub repository page. Open the commit history and confirm that it shows both messages in this order, newest first:
Update journal footerCreate semantic HTML journal
Finally, run:
git statusgit log --onelineExpected result: The working tree is clean, and the log shows both commits.
If it does not work
Section titled “If it does not work”- If
git statusis clean before the second commit, saveindex.htmland confirm that the footer text changed in the source file. - If
git commitreports nothing to commit, rungit status. Stage the saved file withgit add index.htmlwhen it is listed as modified. - If GitHub still shows one commit, run
git pushand reload the repository page after the command succeeds.
Self-check
Complete these checks against the required result.
- Run git status and confirm that the branch is main and the working tree is clean.
- Run git log --oneline and identify the two commit messages.
- Run git remote -v and identify origin as the GitHub connection.
- Open the private GitHub repository and confirm that index.html contains the revised footer.
- Explain which command inspects an unstaged change and which command inspects the staged version.
- Explain why saving a file, committing it, and pushing it are three separate actions.
Use the workflow on your own projects
Section titled “Use the workflow on your own projects”For a small solo project, use this loop at a meaningful working checkpoint:
Edit and save→ git status→ git diff→ git add FILE→ git diff --staged→ git commit -m "Describe the completed change"→ git pushCommit a coherent result that you can name. Examples include Add profile navigation, Add project entries, or Fix contact link target. A commit message such as stuff does not tell your future self what changed.
Git does not replace saving the file. A commit does not automatically reach GitHub. A push does not include unstaged or uncommitted changes.
For the small profile-page project, working on main is a suitable solo workflow. A separate branch becomes useful when you want to isolate an experiment or when a project has a review and merge process.
Where teamwork fits
Section titled “Where teamwork fits”The same Git model supports teamwork. Team members can work on separate branches, push them to a shared remote, review changes in a pull request, and merge accepted commits. Two people can also change the same lines and create a merge conflict that they must resolve.
Those collaboration steps are not required in this lesson. The current focus is the individual workflow that teamwork builds on: inspect your changes, make clear commits, keep your local state understandable, and push the commits that belong on the remote.
Assistance 2 — Map each Git term to the project state
- Working tree: The current saved files in
html-elements. - Staging area: The exact file content selected by
git addfor the next commit. - Commit: A recorded project snapshot and message in the local history.
- Branch: The named line of commits. This lesson uses
main. - Remote: The saved connection named
origin. - Push: The operation that sends local commits to the connected GitHub branch.
Official references
Section titled “Official references”Use these references when an interface or setup differs from the lesson:
- Install Git for Windows
- Set your Git username
- Set your commit email address
- Add locally hosted code to GitHub
- Use Git Credential Manager on Windows
Next step or safe stopping point
Section titled “Next step or safe stopping point”The lesson is complete when the local and GitHub repositories show both commits, git status is clean, and you can explain the solo workflow from edit to push.
Continue to How websites work to compare the local HTML journal with a page requested from a web server.
If you stop here, leave yourself this resume note: The html-elements repository is clean and pushed. Next, open the How websites work lesson with the local journal ready in the browser.