How to Upload an Eclipse Java Project to Github

Step-By-Stride Guide To Push Your First Project On GitHub!!

image

Akash HackerNoon profile picture

@ skyline

Akash

Programmer || Writer || Engineer

Steps that can brand your work half!!
Commencement select your projection & open your terminal in your project's root directory.

1. Check for Git Version

                              git --version                                          
If it is not showing the version of git and then go to the official website of git and download the git co-ordinate to Os of your organization.

two. If we are setting up the git for the first time, nosotros tin configure the git with name & email.

                              git config --global user.name "Your_Name" git config --global user.email "Your-Email"                          

iii. Initialize Git Repository

                              git init                          
Note:- On your Project'south root directory
It initializes the git repository in local projection & volition brand . git folder that contain important folders and files.

4. Commiting files into the git repo.

There are iii steps :-

Footstep one : We need to add together a file to staging expanse .

                              git add <File_Name>  {{For Single File}} git add .            {{For all the files in current Directory}}                          
Note :- In place of <File_Name> add together your file and if y'all want select all the files in current directory then use {{ . }} or {{ * }}
Staging area :- Staging area is that area where we can buy some items and put them in saucepan .

To check,if files are added or not,use this:

                              git status                          

Step two : Commit a file into the git repo is to write a commit message.

thou = message
                              git commit -1000 "First Commit"                          
Note :- In the "Double Quotes", you should write your message.

Stride 3 : Button the file into a remote repository. {{Github}}

At present create your account on git-hub and create a repository .
To add together files in your remote repo use this :
                              git remote add together origin [email protected]:"Username_on_github"/"Repository_Name"                          
Annotation :- This above command is a single command & Now place your git-hub username (without any quotes) and put your repository name (without whatever quotes).

Like this

                              git remote add origin [email protected]:XYZ/project.git                          
And if you don't empathize this then become to your repository on git-hub and click on clone or download button and re-create url with SSH method.

To check

                              git remote -v                          

5. Create SSH Key.

Why nosotros utilize SSH?
By using the ssh protocol, we can connect and cosign to remote servers and services. With ssh keys we can connect to GitHub without supplying our username and password at each visit with the help of passphrase.
In HTTPS method, you will need to fill our username and countersign at every visit, which will exist very inconvenient.
Git associates a remote URL with a name and our default remote is usually called "Origin"

1. Generating New ssh key and adding it to a ssh amanuensis.

                              ssh-keygen -t rsa -b 4096 -C "email"                          
Note :- Place your electronic mail in "double quotes".

This creates a new ssh central using the provided email every bit a label.

1.1. For default file Press {{ ENTER }}

                              /domicile/{{username_of_pc}}/.ssh/id_rsa: ENTER                          

ane.two. Enter a passphrase.

one.3. At present our identification has been saved in

                              Private Primal : /dwelling/{{username_of_pc}}/.ssh/id_rsa & Public Key : .ssh/id_rsa.pub                          

2. Adding our ssh cardinal to the ssh agent

                              eval "$(ssh-agent -s)" it gives like {{agent_id : 15800}}                          

3. Now we add SSH Private fundamental to ssh-agent to our default path.

                              ssh-add ~/.ssh/id_rsa                          

iv. Calculation a new ssh primal to your github account.

Copy the ssh primal to our clipboard.
  1. Automatic Method (Using Xclip)
                              On Ubuntu sudo apt-become install xclip                          
                              on Manjaro Open Octopi -> Download Xclip                          
                              Xclip-set clip <~/.ssh/id_rsa.pub                          

two. Transmission Method

                              Home/.ssh/id_rsa.pub Open this file and copy your key.                          
Now goto github.com ➢➢ Under Profile Photo (Driblet Down) ➢➢ Settings ➢➢ Apply SideBar {{ SSH & GPG Keys }} ➢➢ So go to this directory on your computer {{Abode/.ssh/id_rsa.pub}}
Open this file and copy yourkey.
Create new SSH primal ➢➢ Title the filed with descriptive label ➢➢ Paste key into a "Cardinal Field" ➢➢ Click on {{ Add SSH Key }}

five. Now for Testing SSH Connexion.

                              ssh -T [e-mail protected]                          

After running this , information technology will testify this messege on final!!

                              Hello {{ USERNAME }}! You lot've successfully authenticated but github does not provide crush access.                          

6. Final PUSH

                              git pull --rebase origin master  git push origin principal                                          
Notation : Change 'chief' any branch to button.
Then you can successfully push your file to remote server and you lot tin can setup a SSH Connexion.

To check the connection

                              git log                          

Another useful git concepts.

There are concepts that can help yous to understand the git more securely.

1. Create a new branch.

                              git checkout -b Branch_name                          

If yous want to switch back to master branch.

                              git checkout master                          

If you lot desire to delete the branch.

                              git branch -d Branch_name                          

2. Update and Merge.

To update local repository to the newest commit

                              git pull                          

To merge some other branch in active co-operative.

                              git merge <branch>                          
In both cases git tries to auto-merge changes. unfortunately this is not ever possible and results are in conflicts.

we can merge those conflicts manually past editing the files shown by git.

                              git add <filename>                          

Before merging changes nosotros can preview.

                              git diff <source-branch> <target-branch>                          

3. Tagging.

nosotros can give tag (line i.0.0)

                              git tag 1.0.0 {{1b2eld63ff}}                          
Annotation: {{ this is the first x characters of commit id. }}

4. Git Log.

By Git Log we can study repository history.

Avant-garde :

  1. Meet simply the commits of a certain author.
                              git log --author <proper noun>                          

ii. Very compressed log.

                              git log --pretty=oneline                          

More than preferable format

                              git log --pretty=format:"%h - %an, %ar : %due south"                          

3. It will just show the files that have changed.

                              git log --stat                          

5. Replace Local Changes.

                              git checkout --filename                                          
(if we did something incorrect) then this will replace file with the last content in Caput.

If nosotros want to drib all local changes and commits, fetch the latest history from server

                              git fetch origin git reset --hard origin/principal                          

six. Never forget to create your .gitignore file.

Gitignore file ➢➢ Is a file that specifying the files or folders that we want to ignore.

There are several ways to specifying those

  • Firstly, yous can specifying by the specific filename. Here is an example, let's say we want to ignore a file called readme.txt, then we just need to write readme.txt in the .gitignore file.
  • Secondly, we can likewise write the name of the extension. For example, we are going to ignore all.txt files, then write*.txt.
  • In that location is too a method to ignore a whole folder. Let's say nosotros want to ignore folder named test. And so nosotros can just write test/ in the file.

Like this

image

.gitignore file

Useful Hints

1. Built in git Gui.

                              gitk                          

two. Use colorful-git output.

                              git config color.ui true                          

iii. Use interactive adding.

                              git add -i                          

Some useful Article's and Repositories

  • github/hub {{ A command-line tool that makes git easier to use with GitHub}}
  • 15 Git Commands You May Non Know
  • Adding an existing project to GitHub using the control line
  • How to go a Git good

For GitIgnore

  • Git- gitIgnore Documentation.
  • .gitignore file — ignoring files in Git | Atlassian Git Tutorial
  • gitignore.io

image

Photo by Pankaj Patel on Unsplash
Lastly, You are requested to share your views on this article. :)
Find something useful? Hold downwardly the 👏 to back up and aid others observe this article. Cheers for reading!!
Follow me on Instagram @hypnosisss___ :)

Tags

# projects# git# github# code# repositories

Related Stories

sadlervaniffew.blogspot.com

Source: https://hackernoon.com/step-by-step-guide-to-push-your-first-project-on-github-fec1dce574f

0 Response to "How to Upload an Eclipse Java Project to Github"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel