Skip to main content

Command Palette

Search for a command to run...

Connecting Git to GitHub (with PAT Token)

Updated
โ€ข3 min read

๐Ÿš€ Introduction

So far, youโ€™ve learned the basics of Git and GitHub. But how do you actually connect your local project to GitHub? Thatโ€™s where Personal Access Tokens (PATs) come in.

GitHub has deprecated password authentication for Git operations, and now recommends using PAT tokens for secure access. In this blog, weโ€™ll walk through the entire process of pushing a new project from your computer to GitHub โ€” step by step.


๐Ÿง‘โ€๐Ÿซ Step 1: Configure Git (only once per computer)

Before pushing anything, you need to tell Git who you are. Run these commands in your terminal:

git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
git config --global credential.helper store

๐Ÿ‘‰ This sets up your identity and ensures Git can store credentials for future use.


๐Ÿง‘โ€๐Ÿซ Step 2: Create a Spring Boot project

For this example, letโ€™s create a demo project using Spring Initializr:

  1. Go to ๐Ÿ‘‰ https://start.spring.io/
  2. Select:

    • Project: Maven
    • Language: Java
    • Spring Boot: latest stable
    • Group: com.example
    • Artifact: demo
    • (Optional) Add Spring Web dependency
  3. Click Generate Project โ†’ a .zip file will download.
  4. Extract the project and open it in your IDE (IntelliJ IDEA or VS Code).

๐Ÿง‘โ€๐Ÿซ Step 3: Create an empty GitHub repository

Next, letโ€™s set up a remote repository on GitHub:

  1. Log in to ๐Ÿ‘‰ https://github.com.
  2. Click New Repository.
  3. Enter repo name โ†’ spring-demo.
  4. โš ๏ธ Keep the repository empty (donโ€™t add README, .gitignore, or license).
  5. Click Create Repository.

๐Ÿง‘โ€๐Ÿซ Step 4: Generate a PAT (Personal Access Token)

Now we need a PAT to authenticate securely:

  1. Go to ๐Ÿ‘‰ GitHub Settings โ†’ Developer Settings โ†’ Personal access tokens.
  2. Click Tokens (classic) โ†’ Generate new token (classic).
  3. Fill in details:

    • Name: spring-project-token
    • Expiration: 30 days (or as needed)
    • Permissions: โœ… repo
  4. Click Generate token.
  5. Copy the token (e.g., ghp_abc123XYZ...) and save it somewhere safe.

๐Ÿง‘โ€๐Ÿซ Step 5: Connect local project to GitHub

Open your terminal inside the Spring project folder and run:

git init
git remote add origin https://github.com/your-username/spring-demo.git
git add .
git commit -m "Initial Spring Boot project"
git branch -M main
git push -u origin main

๐Ÿง‘โ€๐Ÿซ Step 6: Authenticate with GitHub

When you run the push command:

  • Git will ask for username โ†’ enter your GitHub username.
  • Git will ask for password โ†’ paste your PAT token.

๐ŸŽ‰ Step 7: Verify on GitHub

Finally, go to your repository on GitHub. You should now see your Spring Boot project uploaded successfully ๐Ÿš€


๐ŸŽฏ Conclusion

Thatโ€™s it! Youโ€™ve just connected your local Git project to GitHub using a Personal Access Token.

  • Git is now configured on your machine.
  • Your project is securely stored in GitHub.
  • Youโ€™re ready to collaborate with others.

This process is a one-time setup per project โ€” once done, future pushes will be much simpler.


โœ… Next Steps

๐Ÿš€ Be interview-ready in the era of AI & Cloud โ€” start your DevOps journey today!
๐Ÿ’ก YouTube wonโ€™t get you a job. Real projects + real internship certificate will.
๐Ÿ”ฅ AI is reshaping jobs. Donโ€™t watch it happen, be part of it with DevOps & Cloud skills.
๐ŸŽฏ โ‚น2000/month today = Dream job tomorrow. Secure your spot now.
โณ Every month you wait, Cloud + AI jobs are being filled. Donโ€™t miss out!
๐ŸŒ DevOps + AWS + AI = The skillset every recruiter is hunting for in 2025.

๐Ÿ‘‰ Register now at TechEazy Consulting


Mastering Git and GitHub

Part 5 of 6

A beginner-friendly series that takes you from the basics of version control with Git to advanced collaboration workflows on GitHub. Perfect for students, developers, and anyone looking to understand modern software development practices.

Up next

Introduction to Git and GitHub: A Beginnerโ€™s Guide

๐Ÿš€ Introduction If youโ€™ve just started your journey into software development, youโ€™ve probably heard people talking about Git and GitHub. They might sound similar, but they serve different purposes โ€” and together, theyโ€™re two of the most powerful too...

More from this blog

TechEazy Consulting

34 posts