How to Push to a GitHub Repository in IntelliJ

Image
1. Initialize and Connect the Git Repository # Run in the terminal from the project root git init git remote add origin https://github.com/[user]/[repository].git 2. Configure Git in IntelliJ Select VCS → Enable Version Control Integration . Choose Git and click OK . 3. Connect Your GitHub Account Go to File → Settings (on Windows) or IntelliJ IDEA → Preferences (on macOS). Navigate to Version Control → GitHub . Click Add Account ( + ). Select Log In with Token... and enter your GitHub Personal Access Token. 4. Add and Commit Files Go to VCS → Git → Add (or use the shortcut Ctrl+Alt+A ). Select the files you want to commit. Go to VCS → Commit (or use the shortcut Ctrl+K ). Write a commit message and click Commit . 5. Push Go to VCS → Git → Push (or use the shortcut Ctrl+Shift+K ). Click the Push button. Simpler Method (Using IntelliJ's Built-in Feature) Go to VCS → Share Project on GitHub . Set the repository name to vita-user-...

Mastering GitHub Copilot with IntelliJ

github copilot

If you're developing Spring Boot applications using IntelliJ and GitHub Copilot (paid plan), this post is your ultimate guide. Learn how to generate boilerplate code, auto-generate tests, refactor suggestions, and much more—all using AI-powered assistance.

Supported IDEs

  • IntelliJ IDEA (Community & Ultimate)
  • Visual Studio Code
  • ⚠️ Requires GitHub Copilot Chat plugin installed

Summary of GitHub Copilot Usage

Feature Description Example
1. Editor Autocomplete Autocomplete suggestions appear after typing comments or method signatures // Create a REST controller → Press Tab
2. Copilot Chat + Slash Commands Use commands like /explain, /doc, /test to analyze, document, or test code /explain → describes what the code does
3. Natural Language Requests Ask questions conversationally without a slash Generate a method that filters users over 18 years old
4. Right-click Copilot Chat Select code → right-click → choose Copilot Chat actions "Explain Code with Copilot Chat"
5. File-wide Suggestions Copilot can suggest full class structure from a file name or comment // UserService implementation → generates related methods

1. Editor Autocomplete

Writing Inside Source Files

Type descriptive comments directly in your code editor to let Copilot auto-suggest solutions:

// Generate a Spring Boot REST controller for managing user data with CRUD endpoints

Copilot will offer a full controller implementation below in gray text. Press Tab to accept the suggestion.

Using Copilot Chat Panel

If Copilot Chat plugin is installed, use the shortcut: Alt + Enter for Windows/Linux (or Option (⌥) or Alt+Return for Mac) to open the chat window.

Then enter a prompt such as:

Generate a Spring Boot REST controller for managing user data with CRUD endpoints

This will display the full class in the chat panel. Copy and paste it into your project.

10 Prompt Examples for Copilot

1. Generate REST Controllers

// Create a Spring Boot REST controller for managing users

2. Remove Boilerplate Code

// JPA entity for User with id, name, and email

3. Generate Exception Handlers

// Global exception handler for ResourceNotFoundException

4. Generate Unit Tests

// Unit test for UserService using Mockito

5. Create Swagger Documentation

/** Create a new user endpoint */

6. Write Repository Methods

// Custom JPA query to find users by email

7. Add Dependencies in pom.xml

8. Business Logic

// Logic to place an order and save to database

9. Refactoring Suggestions

// TODO: split this method into smaller functions

10. Generate Comments

// This method calculates the total price of the cart

Tip: Use clear and detailed prompts. Avoid vague ones like // generate user. Instead, try // Generate a Spring Boot REST controller for managing user data with CRUD endpoints.

2. What are Slash Commands in Copilot Chat?

Slash commands are shortcuts for Copilot Chat, designed to quickly execute actions like explaining code, writing documentation, or generating tests.

Main Slash Commands

Command What It Does
/explain Describes what the selected code does
/doc Generates JavaDoc-style comments for selected code
/tests Generates JUnit tests for the selected class or method
/fix Analyzes and suggests fixes for bugs or errors
/optimize Recommends refactoring or performance improvements
/simplify Suggests simplifications for selected code
/generate Generates code based on your prompt
/help Lists all available slash commands

How to Use Slash Commands

  1. Select a block of code or place your cursor inside a method.
  2. Open Copilot Chat:
  3. Type a command like: /doc or /test
  4. Review the result in the chat panel and copy it into your code.

Example

(1) Selected Code:

public int add(int a, int b) {
    return a + b;
}

(2) In Copilot Chat, type:

/doc

(3) Result:

/**
 * Adds two integers and returns the result.
 * @param a first number
 * @param b second number
 * @return sum of a and b
 */

Final Tips

  • If Copilot shortcuts don’t work, check for conflicts in IntelliJ’s keymap settings and reassign as needed.
  • Use natural language prompts—be as specific as possible.
  • Use slash commands to speed up documentation, testing, and debugging.
  • Copilot is not perfect — Remind users to always review generated code for correctness, security, and style.

Hope this guide helps you get the most out of GitHub Copilot in your IntelliJ Spring Boot workflow. Happy coding!

Comments

Popular posts from this blog

Resolving Key Exchange Failure When Connecting with SecureCRT to OpenSSH

SecureCRT] How to Back Up and Restore SecureCRT Settings on Windows

How to Set Up Vaultwarden (Bitwarden) on Synology NAS (Best Free Alternative to LastPass)