Java SE: Project push GitHub
Java Fundamentals
javase
git
github
project
cloud
Sync maven project to github cloud
4 ways to sync local project on local repo to remote repo on GitHub:
1 Maven Project push to GitHub: CLI gh & clone
To connect a local project on IntelliJ IDEA to GitHub.com, you will need to create a repository on GitHub and then push your local project to the repository. Here’s a step-by-step guide:
From CLI gh
:
- Go to browser and create an account on GitHub.com
- Open on your terminal and install
git
: install git - Open your terminal and install
cli gh
: install CLI gh and log in to GitHub.com - Create repository on GitHub.com: Create a repo
- At the top of your GitHub repository’s Quick Setup page, click the clipboard icon to copy clone GitHub CLI:
gh repo clone AlbertProfe/wiki
. This will initialize the local directory as a Git repository with a copy of remote repository. - Create Maven Project within that directory/repository local git: create Maven Project
- Upload/sync/push:
git commit and push
from CLI or from IntelliJ IDEA: Commit and push changes to Git repository
1.1 Screen-shoots step-by-step after installing git and github (2022-12-19)
First, install git
and CLI gh
and create a GitHub.con account.
2 Maven Project push to GitHub: from IntelliJ IDEA VCS
- Open your IntelliJ IDEA project.
- In the
VCS
menu, select the option to enable version control integration. - Select
Git
as the version control system. - Add the files in your new local repository. This stages them for the first commit.
- Commit the files that you’ve staged in your local repository.
- In the
VCS
menu, select the option to create anew repository
. - Choose the location for the repository and click the
Create
button. - In the
VCS
menu, select the option to push changes. - Enter your
GitHub login credentials
and click thePush
button.
Now your local project is connected to the repository on GitHub and any changes you make locally will be reflected in the repository on GitHub.
3 Maven Project shortest way: from IntelliJ IDEA git init
- Version Control > Create Git Repository
- Create Remote Repo on GitHub.com and copy HHTPS direction
- Commit and Push and when IntellJIdea ask for Remote Repo Direcion paste it
4 Maven Project push to GitHub: CLI git
Once the Maven Project Java SE
is created, we are going to control its versions with git and upload to GitHub.com by CLI git/gh.
We need:
Github.com
account created and logged ingit
andgh
installedgh
logged toGitHub.com
- Maven Project Java SE created
Code bash linux git/gh
albert@albert-VirtualBox:~/MyProjects/Sandbox/Hello11$ git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /home/albert/MyProjects/Sandbox/Hello11/.git/
albert@albert-VirtualBox:~/MyProjects/Sandbox/Hello11$ git config user.name "albert"
albert@albert-VirtualBox:~/MyProjects/Sandbox/Hello11$ git config user.email "albertprofe@gmail.com"
albert@albert-VirtualBox:~/MyProjects/Sandbox/Hello11$ git add .
albert@albert-VirtualBox:~/MyProjects/Sandbox/Hello11$ git commit -m "crete project"
[master (root-commit) 4cd7009] crete project
7 files changed, 171 insertions(+)
create mode 100644 .gitignore
create mode 100644 .idea/.gitignore
create mode 100644 .idea/encodings.xml
create mode 100644 .idea/misc.xml
create mode 100644 pom.xml
create mode 100644 src/main/java/org/example/App.java
create mode 100644 src/test/java/org/example/AppTest.java
albert@albert-VirtualBox:~/MyProjects/Sandbox/Hello11$ gh repo create hello11 --public
✓ Created repository AlbertProfe/hello11 on GitHub
albert@albert-VirtualBox:~/MyProjects/Sandbox/Hello11$ git remote add origin https://github.com/AlbertProfe/hello11.git
albert@albert-VirtualBox:~/MyProjects/Sandbox/Hello11$ git push -u origin master
Enumerating objects: 19, done.
Counting objects: 100% (19/19), done.
Delta compression using up to 4 threads
Compressing objects: 100% (10/10), done.
Writing objects: 100% (19/19), 2.64 KiB | 675.00 KiB/s, done.
Total 19 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/AlbertProfe/hello11.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
albert@albert-VirtualBox:~/MyProjects/Sandbox/Hello11$