Hey everyone π
If youβre just starting out with Git and GitHub, pushing your first local project online can feel like a big step β especially when weird errors show up that seem like they're written in a secret developer language.
I just went through the full process of taking a local Git repository, linking it to GitHub, and solving some real issues (GH007, 403 errors, email visibility blocks β all the fun stuff π).
Hereβs the step-by-step I wish I had when I first started π
π§± Step 1: Set Up Your First Local Git Repository
This is how you build the foundation of your project version control:
# Create a new folder for your project
mkdir git_practice
cd git_practice
# Initialize Git tracking
git init
# Add a README file
echo "Hello Git and GitHub" >> README.txt
# Stage and commit your first file
git add README.txt
git commit -m "First commit"
Boom π₯ β you now have a working Git project on your machine.
π Step 2: Connect to GitHub
Now letβs get this online:
- Create a new repository on GitHub (donβt initialize it with a README).
- Back in your terminal, run:
git remote add origin https://github.com/YOUR_USERNAME/YOUR_REPO.git
git branch -M main
git push -u origin main
But wait β hereβs where the drama began π
β οΈ The β403 Errorβ and the Rise of the Personal Access Token
When I tried to push, I got this error:
remote: Permission to 1suleyman/test.git denied
fatal: unable to access 'https://github.com/...': The requested URL returned error: 403
Turns out, GitHub no longer accepts passwords for pushing over HTTPS. You need a Personal Access Token (PAT) instead.
π οΈ Fix:
- Go to GitHub β Settings β Developer Settings β Tokens (Classic)
- Generate a new PAT with
repo
access - When Git asks for your password, paste the PAT instead (your username stays the same)
π Then Came GH007: Email Privacy Block
Next, I hit this:
remote: error: GH007: Your push would publish a private email address.
GitHub was protecting my private email from being exposed in my commit. Respect that β but it also blocked the push.
π οΈ Fix:
Use your GitHub no-reply email for commits. You can find it under GitHub Email Settings.
Set it like this:
git config --global user.name "1suleyman"
git config --global user.email "[email protected]"
Then amend the commit to update the author:
git commit --amend --author="1suleyman <[email protected]>" --no-edit
𧨠Final Push (With Force)
Because I changed the author of a commit that was already pushed (or tried to push), I had to use --force
to overwrite the old history:
git push -u origin main --force
π Success! The commit finally appeared on GitHub β clean, private, and tracked.
β Quick Recap
Step | Command / Action |
---|---|
Initialize repo | git init |
Make a commit |
git add β git commit
|
Link to GitHub |
git remote add origin URL β git push
|
Use a PAT instead of password | Generate on GitHub and paste when prompted |
Fix email privacy error | Use GitHubβs no-reply email in git config
|
Update author | git commit --amend --author="..." --no-edit |
Final push | git push -u origin main --force |
π§ What I Learned
- Git errors are part of the learning curve β they teach you how things really work.
- Using a Personal Access Token is now mandatory for GitHub over HTTPS.
- Your email privacy settings matter when contributing to public repos.
- You can fix a lot with
git commit --amend
andgit config
.
π¬ Final Thoughts
It took a few tries and some deep diving, but I now understand Git way better than I did before β and pushing my first project to GitHub feels great.
If you're just getting started with Git, hang in there β every error is a lesson in disguise π
Want help pushing your own repo? Drop a comment or message me on LinkedIn! Iβd love to help others skip the same headaches π
Top comments (0)