1. Setting Up Git in Visual Studio Code
VS Code has built-in Git integration. First, install and configure Git on your system. Then open your Java project folder in VS Code, and the Source Control view (icon on left) will detect the repo.
In VS Code's bottom status bar you will see branch names, sync icons, and option to publish if it's not yet linked to remote.
2. Creating a New Java Project Locally
In your local folder, create a standard Java project structure: `src/`, `bin/`, `pom.xml` or `build.gradle` (if using Maven/Gradle). Open the folder in VS Code and start writing Java code (e.g. `Main.java`).
Use extensions like “Java Extension Pack” for VS Code to get IntelliSense, compilation, and debugging support.
3. Git Commands: init / add / commit / reset / push
Once your project is ready, you initialize Git, stage files, commit changes, and push to remote. If needed, you can reset changes to previous state.
git init
git add .
git commit -m "Initial commit from NBKRIST student"
git log
# Reset (soft or mixed)
git reset --soft HEAD~1
git reset --hard HEAD~1
After initialization and committing locally, configure remote and push your code.
4. Linking Remote Repository & Pushing to GitHub (nbkristrepo)
Connect your local repository to GitHub’s remote repo (for example: `nbkristrepo`) and push your commits.
git remote add origin https://github.com/nbkriststudent/nbkristrepo.git
git branch -M main
git push -u origin main
# Later pushes
git push origin main
After the first push, you can simply use `git push` to send new commits to GitHub.
5. Cloning Remote Repository Locally
If you or another team member wants to work on the remote project, clone it locally using Git.
git clone https://github.com/nbkriststudent/nbkristrepo.git
cd nbkristrepo
After cloning, open the folder in VS Code and work as usual.
6. Pull, Add, Commit, Push in a Remote Workflow
Regularly update your local copy with remote changes, then stage new changes, commit them, and push back.
git pull origin main
# make changes in files...
git add .
git commit -m "Updated some feature"
git push origin main
This ensures your code stays in sync with team and remote.