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 "110779287+1suleyman@users.noreply.github.com"
Enter fullscreen mode Exit fullscreen mode

Then amend the commit to update the author:

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