DEV Community

TechEazy Consulting
TechEazy Consulting

Posted on • Edited on

Connecting Git to GitHub (with PAT Token)

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

👉 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
    1. Click Generate Project → a .zip file will download.
    2. 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
    1. Click Generate token.
    2. 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
Enter fullscreen mode Exit fullscreen mode

🧑‍🏫 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


Top comments (0)