DEV Community

1suleyman
1suleyman

Posted on

πŸš€ From Local Repo to GitHub – Your First Commit and Push

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"
Enter fullscreen mode Exit fullscreen mode

Boom πŸ’₯ β€” you now have a working Git project on your machine.


🌐 Step 2: Connect to GitHub

Now let’s get this online:

  1. Create a new repository on GitHub (don’t initialize it with a README).
  2. 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Turns out, GitHub no longer accepts passwords for pushing over HTTPS. You need a Personal Access Token (PAT) instead.

πŸ› οΈ Fix:


πŸ›‘ Then Came GH007: Email Privacy Block

Next, I hit this:

remote: error: GH007: Your push would publish a private email address.
Enter fullscreen mode Exit fullscreen mode

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]"
Enter fullscreen mode Exit fullscreen mode

Then amend the commit to update the author:

git commit --amend --author="1suleyman <[email protected]>" --no-edit
Enter fullscreen mode Exit fullscreen mode

🧨 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
Enter fullscreen mode Exit fullscreen mode

πŸš€ 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 and git 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)