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 "110779287+1suleyman@users.noreply.github.com"
Then amend the commit to update the author:
git commit --amend --author="1suleyman <110779287+1suleyman@users.noreply.github.com>" --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)