Track a Project with Git and GitHub
Learn Git by building a portfolio repo with commits, branches, and GitHub.
Introduction
30 Second Summary
Every developer has been there. You rename a file final_v2_REAL_final.docx and immediately lose track of what changed and when. Version control solves this chaos by recording every change you make to a project, letting you travel back in time whenever you need to.
In this project, you will install Git on your computer, track a small portfolio project through multiple commits and branches, and publish it to GitHub so it's live on your profile.
What You'll Build
You'll create a personal portfolio project tracked with Git and published to GitHub, demonstrating a professional version control workflow.
By the end of this project, you'll have:
- A local Git repository with a meaningful commit history tracking a small project.
- A feature branch merged into main demonstrating a real branching workflow.
- A public GitHub repository showcasing your work visible on your profile.
- Secret Mission: Resolve a merge conflict by making competing changes on two branches, then merge them together.
Are there any prerequisites?
None. This project includes full setup instructions for every tool you need. You don't need any prior experience with Git, GitHub, or the command line.
Install Git and Configure Your Identity
Every professional development team uses version control to track changes to their code.
In this step, you will install Git on your Windows machine and configure it with your identity so that every change you track is stamped with your name.
In this step, get ready to:
- Install Git for Windows using PowerShell.
- Configure your name and email for Git commits.
- Set the default branch name to main.
Install Git for Windows
Git is a command-line tool that tracks every change you make to your files. Before writing any code, you need it installed on your machine.
- Press the Windows key to open your search bar.
- Type PowerShell and press Enter to open it.
- Check whether Git is already installed by running this command:
git --version
✔️ I see version 2.28 or higher
Git is already installed and ready to go. Skip ahead to the next substep where you configure your identity.
ⓧ I see an older version
Your version of Git is too old for some features this project uses. You need version 2.28 or higher.
- Upgrade Git to the latest version by running this command:
winget upgrade --id Git.Git -e --source winget
- Accept any prompts that appear during the upgrade.
- Close PowerShell and open a new PowerShell window.
- Run git --version again to confirm the version is now 2.28 or higher.
ⓧ Command not found
Git is not installed yet. You will install it using winget, the Windows package manager.
- Install Git by running this command:
winget install --id Git.Git -e --source winget
What does this command do?
This tells winget to install the exact package with ID Git.Git from the winget source. The -e flag ensures an exact match so you get the right package.
- The installer will run and display progress in your terminal. Accept the default options if any prompts appear.
- Close PowerShell completely after the installation finishes.
- Open a new PowerShell window by pressing the Windows key, typing PowerShell, and pressing Enter.
- Confirm Git is installed by running:
git --version
You should see a version number like git version 2.54.0.windows.1 in the output.
Seeing 'winget' is not recognized?
The winget tool comes pre-installed on Windows 10 (version 1709+) and Windows 11. If your system does not recognize the command, download Git directly from git-scm.com/download/win and run the installer manually.
help me install Git on Windows
Configure your identity
Git stamps your name and email on every commit you make. This is how teammates know who made each change.
- Set your name by running this command:
git config --global user.name "[[YOURNAME="Your Name"]]"
- Set your email by running this command:
git config --global user.email "[[YOUREMAIL="your-email@example.com"]]"
What do these commands do?
The --global flag saves these settings for all Git projects on your machine. Without it, you would need to set your name and email separately in every project.
Use the same email address you plan to use for your GitHub account. This links your local commits to your GitHub profile later.
Made a typo in your name or email?
Run the same command again with the correct value. The new value overwrites the old one.
help me fix my Git config settings
Set your default branch name to main
When you create a new Git repository, Git names the first branch master by default. The modern convention (and GitHub's default) is main.
- Set your default branch name to main by running this command:
git config --global init.defaultBranch main
Why main instead of master?
GitHub uses main as the default branch name for new repositories. Setting this locally keeps your repositories consistent with GitHub.
- Verify all your settings are saved by running:
git config --list
You should see your name, email, and default branch name in the output. Look for lines like user.name=Your Name, user.email=your-email@example.com, and init.defaultbranch=main.
✔️ Awesome, I see my settings
Great. Your Git identity is configured and ready to use.
ⓧ I don't see my name or email
- Make sure you included the --global flag when you ran the config commands.
- Run git config --global user.name (without a value) to check what is currently stored. If it returns nothing, re-run the full command with your name in quotes.
help me check my Git configuration
Your Git installation is configured and ready to track changes. Next up, you will create your first repository and start building a commit history.
Create Your First Repository and Commit
Git is installed and ready to go. Now it's time to put it to work on a real project.
A repository tracks every change you save as a permanent snapshot called a commit. In this step, you'll create your first repository and build up a commit history with two meaningful commits.
In this step, get ready to:
- Initialize a local Git repository.
- Create and commit a README file.
- Create and commit a .gitignore file.
Initialize a Git repository
Every Git project starts with git init. This command creates a hidden .git folder that stores your entire project history.
- Move to your Desktop by running this command:
cd ~/Desktop
- Create your project folder, move into it, and initialize a Git repository by running these commands:
mkdir my-portfolio
cd my-portfolio
git init
What does this do?
- mkdir my-portfolio creates a new folder called my-portfolio on your Desktop.
- cd my-portfolio moves your terminal session into that folder.
- git init creates the hidden .git directory that turns this ordinary folder into a Git repository.
- You should see a message that says:
Initialized empty Git repository in C:/Users/.../Desktop/my-portfolio/.git/
The exact path will match your computer's username. This confirms your repository is ready.
Don't see the initialization message?
- Make sure you ran the commands inside the my-portfolio folder. Your PowerShell prompt should end with my-portfolio.
- If you see an error like "git is not recognized", close PowerShell and reopen it. Git needs a fresh terminal session after installation.
Help me troubleshoot my git init command.
Create your first file and make your initial commit
A repository without files is just an empty container. Your first file will be a README.md, which is the front page of any project on GitHub.
- Create and open your README.md file by running:
notepad README.md
Notepad will ask to create a new file
Since README.md doesn't exist yet, Notepad will ask if you want to create it. Click Yes to continue.
- Type the following content into Notepad, replacing the placeholders with your own name and description:
# [[YOURNAME="Your Name"]]
[[PROJECT_DESCRIPTION="A one-line description of your project"]]
Keep it simple
Your description can be something like "A personal portfolio project to showcase my skills." You'll add more content later.
- Save the file by pressing Ctrl+S.
- Close Notepad.
Your file exists on disk, but Git doesn't know about it yet. In Git, you must explicitly tell it which changes to include in your next commit. This is called the staging area.
- Stage your new file and commit it by running these commands:
git add README.md
git commit -m "Add initial README with project description"
What does this do?
- git add README.md moves the file into the staging area. Think of it as placing items into a box before sealing it.
- git commit -m "..." seals the box. The -m flag lets you attach a descriptive message explaining what this commit does.
- Verify your first commit by running:
git log
You should see one commit entry showing your name, email, and the message "Add initial README with project description".
Seeing an error about identity?
- If Git says it doesn't know who you are, your global config from Step 1 may not have saved. Run git config --list to check that user.name and user.email are set.
- If the commit message has a typo, don't worry. You can continue. Commit messages can be amended later with git commit --amend.
Help me fix my first git commit.
Add a .gitignore and make a second commit
Not every file belongs in version control. Files like environment secrets, dependency folders, and OS-generated junk should stay out of your repository. A .gitignore file tells Git which files to completely ignore.
- Create and open your .gitignore file by running:
notepad .gitignore
- Notepad will ask to create the new file. Click Yes.
- Type the following content into Notepad:
.env
node_modules/
Thumbs.db
What are these files?
- .env files store secret values like API keys. They should never be shared.
- node_modules/ is a folder that package managers generate automatically. It can contain thousands of files that don't need tracking.
- Thumbs.db is a hidden file Windows creates for image thumbnails. It's system junk that clutters your project.
- Save the file by pressing Ctrl+S.
- Close Notepad.
- Stage and commit your .gitignore file by running these commands:
git add .gitignore
git commit -m "Add .gitignore to exclude system and environment files"
What does this commit message do?
Good commit messages describe the change, not just the file. "Add .gitignore to exclude system and environment files" tells future readers why this file exists in one glance.
- Verify your growing history by running:
git log --oneline
You should see two commits listed, with the most recent at the top. Each line shows a short hash and the commit message.
Only seeing one commit?
- Make sure you ran both git add .gitignore and git commit for the second file. Staging alone does not create a commit.
- If you accidentally committed both files together, that's OK. Your history will just show one commit instead of two. You can keep going.
Help me check my commit history.
✔️ Awesome, I've got everything!
Great. Make sure both files are saved and you can see two commits in your git log --oneline output.
ⓧ I'd like to double check the full code
Here's what each file should contain:
# [[YOURNAME="Your Name"]]
[[PROJECT_DESCRIPTION="A one-line description of your project"]]
.env
node_modules/
Thumbs.db
Your git log --oneline output should show two commits (most recent first):
a1b2c3d Add .gitignore to exclude system and environment files
e4f5g6h Add initial README with project description
Your hash values (the letters and numbers on the left) will be different. That's expected.
You now have a repository with a real commit history. Next up, you'll learn how to work on new features without touching your main code using branches.
Work with Branches
Your repository now has two commits tracking your project's foundation. Next up, you'll use branches to work on a new feature without risking your stable code.
Branches let you create an independent line of development. You can experiment, add features, and make changes on a branch without affecting your main project. When you're happy with the work, you merge it back in.
In this step, get ready to:
- Create a feature branch and switch to it.
- Add a Skills section to your README on the feature branch.
- Merge the feature branch back into main.
Create and switch to a feature branch
Instead of making changes directly on main, you'll create a separate branch for your new feature. This keeps your main branch clean until the new work is ready.
- Create a new branch called add-skills and switch to it by running this command:
git switch -c add-skills
What does this command do?
The git switch -c command does two things in one step: it creates a new branch with the name you provide, then immediately switches you onto that branch.
Any changes you make from this point forward are recorded on add-skills only. Your main branch stays exactly as it was.
- Confirm you're on the new branch by running:
git branch
You should see two branches listed. The asterisk (*) appears next to add-skills, confirming it's your current branch.
Don't see add-skills with the asterisk?
Make sure you typed the command exactly as shown, including the -c flag. Without -c, Git tries to switch to an existing branch and will error if it doesn't exist.
If you see an error about the branch already existing, you may have run the command twice. Run git switch add-skills (without -c) to switch to it.
help me fix my git branch issue
Make changes on the feature branch
Now that you're on the add-skills branch, any edits you make to your files will only be tracked on this branch. You'll add a Skills section to your README listing technologies you're learning.
- Open README.md in any text editor (Notepad, VS Code, or whatever you prefer).
- Below your existing description, add a new Skills section. Use this structure as a guide, replacing the placeholder items with 3-5 technologies or tools you're learning:
## Skills
- Git
- PowerShell
- Python
What should I put in my Skills list?
List any technologies, tools, or languages you're currently learning or interested in. Examples include Git, Python, JavaScript, AWS, Docker, HTML, or CSS.
The specific items don't matter for this exercise. What matters is that you're making a real edit to the file so Git can track it.
- Save the file.
Your README.md should now have your name, your project description, and the new Skills section all in one file.
- Stage and commit your changes by running these commands:
git add README.md
git commit -m "Add skills section to README"
What does staging and committing do here?
The git add command moves your edited file into the staging area, marking it as ready for the next commit.
The git commit command saves a snapshot of those staged changes with your message describing what you did. This commit lives on the add-skills branch only.
- Verify your commit was recorded by running:
git log --oneline
You should see three commits listed, with your newest commit at the top.
Seeing an error about nothing to commit?
This means Git doesn't detect any changes to README.md. Make sure you saved the file after adding the Skills section.
Run git status to see whether Git sees your edits. If the file appears under "Changes not staged for commit", run git add README.md again before committing.
help me fix my staging and commit issue
Switch back to main and merge
Your feature is complete on its own branch. Now you'll bring those changes into main by merging. Merging combines the work from one branch into another.
- Switch back to main and merge the feature branch by running these commands:
git switch main
git merge add-skills
What does merging do?
The git switch main command moves you back to your main branch. At this point, main still has the old version of your README without the Skills section.
The git merge add-skills command pulls all the commits from add-skills into main. Since main hasn't changed since you branched off, Git performs a "fast-forward" merge. It simply moves the main pointer forward to include your new commit.
- Verify the merge by viewing your commit history as a graph:
git log --oneline --graph
You should see three commits listed in order, with the most recent at the top. Your Skills commit now lives on main.
- Delete the merged branch since its work is now part of main:
git branch -d add-skills
Why delete the branch?
Once a branch's changes are merged, the branch name is just a leftover pointer. Deleting it keeps your repository tidy. The -d flag is a safe delete. Git refuses to delete the branch if it has unmerged work, so you can't accidentally lose commits.
You should see a confirmation message like Deleted branch add-skills followed by the commit hash it pointed to.
Merge says "Already up to date"?
This means main already contains all the commits from add-skills. You may have accidentally committed your Skills edit while on main instead of add-skills.
Run git log --oneline to check your history. If you see your Skills commit on main, the work is already there and you can continue to the next step.
help me understand my git merge result
Your local repository now has a clean history showing a real branching workflow. Next up, you'll push everything to GitHub so your work is visible online.
Push to GitHub
Your local repository has a clean commit history and a merged feature branch. That work only lives on your computer right now.
In this step, you'll publish your repository to GitHub so your commits are backed up in the cloud and visible on your profile. This is how developers share code and prove their skills to employers.
In this step, get ready to:
- Create a public GitHub repository.
- Connect your local repo to GitHub and push your commits.
- Verify your work is live on your profile.
Create a GitHub repository
You need a place on GitHub to receive your local commits. You'll create an empty repository there, then connect it to your local project.
- Open your browser and go to github.com.
- Sign in to your GitHub account.
Don't have a GitHub account yet?
Click Sign up on the GitHub homepage and follow the prompts. You'll need to verify your email address. GitHub is free for public repositories.
- Click the + icon in the upper-right corner of the page.
- Click New repository.
- In the Repository name field, type my-portfolio.
- Select Public for the visibility.
- Leave all the checkboxes under "Initialize this repository with:" unchecked. Do NOT add a README, .gitignore, or license.
- Click Create repository.
Why skip the README initialization?
You already have a README.md and .gitignore in your local repository. If GitHub creates its own, the two histories will conflict when you try to push. Starting with an empty repository lets you push your existing commits cleanly.
After clicking Create repository, GitHub shows a "Quick setup" page with instructions. Keep this page open. You'll need the HTTPS URL it displays.
Connect your local repo to GitHub and push
A remote is a connection between your local repository and a copy hosted elsewhere. You'll add GitHub as a remote called origin, then push all your commits up to it.
- On the GitHub Quick setup page, find the HTTPS URL. It looks like https://github.com/YOUR-USERNAME/my-portfolio.git.
- Switch back to your PowerShell window (you should still be inside the my-portfolio folder).
- Add the GitHub repository as a remote by running this command:
git remote add origin https://github.com/[[GITHUB_USERNAME="your GitHub username"]]/my-portfolio.git
What does this command do?
git remote add origin registers a new remote connection named origin. The name origin is the standard convention for your primary remote. The URL tells Git where to send your commits when you push.
- Push your local commits to GitHub by running this command:
git push -u origin main
What does this command do?
git push uploads your commits to the remote repository. The -u flag sets origin main as the default upstream branch. After this, future pushes only need git push with no extra arguments.
What will I see when I push?
Git for Windows includes Git Credential Manager, which handles authentication automatically. A browser window will open asking you to sign in to GitHub and authorize the connection. Follow the prompts to allow access.
After authenticating, your terminal will show progress as it uploads objects and refs to GitHub. Your credentials are saved in Windows Credential Manager so you won't need to sign in again for future pushes.
Push failed or permission denied?
Make sure the URL matches what GitHub showed you on the Quick setup page. You can check it by running git remote -v in PowerShell.
If the browser sign-in didn't appear, make sure you installed Git for Windows 2.29 or higher (which includes Git Credential Manager with OAuth support). Run git --version to check.
help me troubleshoot my git push to GitHub failing
Verify on GitHub
- Switch back to your browser.
- Refresh the GitHub repository page.
You should see your README.md rendered with your name, description, and Skills section. Your .gitignore file appears in the file list above it.
- Click the commits link (above the file list, showing "3 commits") to browse your full commit history.
You should see all three commits listed with the messages you wrote earlier. This is the same history you viewed locally with git log, now visible to anyone on the internet.
Don't see your files on GitHub?
Make sure the push completed without errors in your terminal. Look for a line mentioning the branch name main -> main in the output.
If the page still shows the Quick setup instructions, it means nothing was pushed yet. Double-check that you ran git push -u origin main from inside the my-portfolio folder.
help me figure out why my GitHub repository is still empty after pushing
Secret mission
Resolve a Merge Conflict
Merge conflicts happen when two branches edit the same line. In real teams, this is unavoidable. Your challenge: create a conflict on purpose, then resolve it by hand so you know exactly what to do when it happens for real.
Clean Up Your Resources
Clean Up Your Resources
This project runs entirely locally and uses a free GitHub account, so there are no ongoing costs. Decide whether to keep your resources running, pause them to come back later, or delete them entirely.
Resources you used:
- Local my-portfolio folder on your Desktop.
- GitHub my-portfolio repository (public).
- Git for Windows (installed via winget).
- GitHub account (free).
Keep everything running
No action needed. Choose this if you plan to keep building on your portfolio or learning more Git commands.
- Your my-portfolio folder stays on your Desktop and your GitHub repository remains public.
- Git stays installed and ready for future projects.
- Your GitHub account is free with unlimited public repositories, so there is nothing to pay.
Pause - I'll come back to this later
There are no running processes to shut down. Your project is already at rest because Git repositories are just files on disk.
- If you want to hide the repository temporarily, go to your repository page on GitHub, click Settings, scroll to the Danger Zone section, and click Change visibility to set it to Private.
- You can make it Public again at any time from the same settings page.
Delete - I don't want to use this again
Remove all project resources and start fresh. Follow each step below for the resources you want to remove.
Delete the local project folder
- In PowerShell, navigate to your Desktop and remove the folder by running:
cd ~\Desktop
Remove-Item -Recurse -Force my-portfolio
- Run ls to confirm my-portfolio no longer appears in the output.
Delete the GitHub repository
- Go to your my-portfolio repository page on GitHub.
- Click the Settings tab.
- Scroll down to the Danger Zone section and click Delete this repository.
- Follow the confirmation prompts. You will need to type the repository name to confirm.
Uninstall Git for Windows
- In PowerShell, uninstall Git by running:
winget uninstall --id Git.Git -e
- Confirm the uninstall completed by running git --version in a new PowerShell window. You should see an error indicating the command is not recognized.
Delete your GitHub account (optional)
Only do this if you are sure you will never use GitHub again. Your account is free and costs nothing to keep.
- On GitHub, click your profile picture in the upper-right corner, then click Settings.
- In the left sidebar, click Account.
- At the bottom of the page under Delete account, click Delete your account.
- Follow the confirmation prompts. This action is permanent and cannot be undone.
Nice Work!
Nice Work!
You just leveled up your developer toolkit. You've built a real project tracked with Git and published it to GitHub for the world to see.
You've learned how to:
- Initialized a repository from scratch, tracked changes with the staging area, and built a meaningful commit history with clear messages.
- Created a feature branch, worked on it independently, and merged it back into main.
- Connected your local repository to a public remote repository visible on your profile.
- Resolved a merge conflict by hand, proving you can handle competing changes across branches.
Your my-portfolio repository is now live on your GitHub profile. Keep adding to it as you learn new skills.
Ready to quiz yourself?