How to Upload Intellij Project to Github

IntelliJ IDEA Videos

Sharing Your Projection on GitHub

In this web log, we're going to look at how to share code that we've written on our local car to a repository on GitHub.

This weblog post covers the same material every bit the video with some additional tips and tricks. This provides an like shooting fish in a barrel style for people to skim the content quickly if they prefer reading to watching, and to requite the reader/watcher code samples and links to boosted information.

In that location are a few ways to utilise IntelliJ IDEA to publish code that we've written on GitHub. In this web log, we volition become over ii approaches. The commencement is the quickest where you create your local and remote repository in ane step. The 2d approach is multi-step which can exist used when yous want to create a local Git repository for your project separately from publishing any lawmaking publicly on GitHub.

Sharing Your Project on GitHub (Quick Approach)

Let's assume nosotros've created an IntelliJ IDEA projection containing the code we desire to share on GitHub. In this tutorial, we use a sample Howdy World awarding that nosotros know works considering nosotros've seen it run successfully. It's not currently set up with whatever source control, which we can see in IntelliJ Thought considering there'due south no pick for opening a Git window, and if nosotros listing the projection's files in the Terminal window, nosotros can run into at that place's no .git binder in the project. Nosotros can use IntelliJ Idea to share this project on GitHub, we can become to the VCS card and select Share project on GitHub .

Share Project on GitHub

If we're not already logged in to GitHub via IntelliJ IDEA, nosotros'll be shown a log in dialog where we tin can enter our GitHub username and password. This also provides the option to log in using a token from GitHub, but even if we don't select that pick, if we log in with our username and password hither IntelliJ IDEA will generate a GitHub token and utilize that to log in. If y'all don't already have a GitHub account, y'all can employ the Sign up for GitHub link in IntelliJ Thought to create one. If you lot log in with your username and password, and take two-factor authentication enabled for GitHub, IntelliJ IDEA will pop up an boosted dialog asking you to input your authentication code.

Tip: if you have multiple GitHub accounts, you can add together your GitHub accounts by going to the IDE Preferences -> Version Command -> GitHub. Apply the add button to add your accounts.

In one case we're successfully logged in, IntelliJ IDEA volition ask united states of america what we want to call the repository that we're almost to create on GitHub. This defaults to the project name, but nosotros tin can pick any name for this repository, as long equally it follows GitHub'due south guidelines. For my Hello Globe project, I will call our repository hi-world-demo, as repositories have to have a unique name and I'thou certain in that location's already a repository called hello-earth on my GitHub business relationship. Y'all tin can make this repository private if y'all like. I like to make my repositories public, unless there'due south a compelling reason to make them private. You tin rename the remote if you like, simply I will accept the default here. I will as well add together a description too. This isn't mandatory, but it helps people who want to sympathize what the project is for.

Share Project on GitHub Window

When nosotros printing Enter or click Share , IntelliJ IDEA will go ahead and create that repository on our GitHub profile. The IDE will ask the states which files we want to put into this first commit. We could commit everything, simply generally we don't demand to add the .gradle binder (if nosotros're using the Gradle wrapper), and we don't need to add together the build folder, which is where IntelliJ Thought puts the compiler output like grade files.

Add Files for Initial Commit

Everything else looks expert to commit, nosotros'll utilize the default commit message and click Enter to commit it.

Under the covers, IntelliJ Thought is creating a local Git repository for the project and and then pushing it to your GitHub contour as a new repository with the details we merely entered. When this procedure is finished, IntelliJ Thought volition pop up a balloon and nosotros can click on the link to run into the repository in GitHub in a browser. Nosotros can run across the repository, the code, the commit message, and the description.

Shared on GitHub Bubble

Shared on GitHub Browser

View previous steps in video

Sharing Your Project on GitHub (Multi-step Arroyo)

The kickoff arroyo assumed nosotros want to practice everything in a single step. Often we'll want to create a local Git repository for our project well before we desire to publish our lawmaking publicly on GitHub.

Permit's presume we have a more complex projection than Hello World and that we're yet in the process of writing the code. We don't want to publish our project on GitHub simply however, merely nosotros do desire to enable source control for information technology equally we want to do small commits locally while we evolve the lawmaking. Nosotros ofttimes want to salvage our project's progress each step of the way, for example, once the tests are passing. Then, showtime, we will create a local Git repository for this IntelliJ Thought project.

Nosotros start with a project that is not currently under whatsoever source control, and then there's no Git or VCS tool window. To use Git as the version command for an IntelliJ Idea project, go to the VCS menu and select Enable Version Control Integration .

Enable Version Control Integration

IntelliJ IDEA supports multiple version control systems, but for this example we desire to cull Git. IntelliJ Idea creates a Git repository in the root directory of the project. We likewise now have admission to the Git tool window. If we open this, nosotros tin see the Console tab which shows the Git commands that have been run and their result, or we can switch to the visual Log tab. Using IntelliJ IDEA'due south concluding to listing the projection'due south files, we can also see that we at present accept a .git binder in the root of our project.

Now we've enabled Git, but we oasis't added anything to source command nevertheless. We can come across that our files are shown in ruddy, which means every bit far as Git is concerned, these are new files that are not still added to Git, and then they're not in source control. Let'southward select which files we want to be in source control, and make our kickoff commit.

We can open up the commit window using Ctrl+K on Windows/Linux or ⌘K on macOS. The tutorial uses the Commit Tool Window, which was added in IntelliJ Thought 2020.1. If you lot're still using the onetime commit dialog, you can switch to the commit tool window in Preferences -> Version Control -> Commit -> Use non-modal commit interface.

If we open up upward the unversioned files list in this commit window we can see all the files in our project are listed considering none of them take been added to Git yet. We probably don't want to add everything to Git, there are some directories and files, like build output files, that nosotros don't need to put under source control. Seeing all the files in a single list similar this might not exist helpful, so nosotros could opt to group the files, for case by directory or module.

Group by Directory

With this view I tin run into there are two directories that I don't desire to add together to Git, considering they're build directories. I do desire to add the gradle wrapper directory, my source, and the files in the root of my project. If I open up up the .idea binder, I tin see all IntelliJ Idea's settings files. Each squad will accept their own thought of which settings should be saved into source control, if any. IntelliJ Thought automatically adds a .gitignore file to this directory with default folders and files to exclude from source command. We could add together other files to this .gitignore file if at that place are other specific IDE settings that we don't want to include. However, I'm going to add all the other settings files to Git.

Add Versioned Files

Add a clarification for this commit describing what functionality these changes exercise. When we commit this, nosotros get a balloon proverb this was successful. When we go back to the Git window, the Log tab shows us this commit. We can see the files that were inverse in this commit and the commit bulletin. We can hide the Git window by pressing Alt+ix or ⌘nine again.

View previous steps in video

So far we've been committing all these changes to our local Git repository. If you open the Log tab, nosotros can encounter this project only has local branches, which ways all the code and the commit history is just saved on this local computer. Once yous finished setting up your project and are ready to share it and its history publicly on GitHub, go to Git -> GitHub -> Share Project on GitHub .

Share Project on GitHub Alternative

Nosotros recommend not waiting too long to push your project to GitHub since putting the project on a remote server like GitHub means that the code is safely backed up to another location.

If you're already logged in to GitHub via IntelliJ Idea, you don't need to re-authenticate. We need to requite the repository a proper name, this needs to be a unique repository name for the GitHub account it will live in. We tin can rename the remote hither if we similar, or leave it equally origin. We tin optionally add together a description to aid others understand what this project is. When we press Enter or Share, IntelliJ Idea will create a new repository on GitHub under the account and push this code to that repository. The balloon notification shows when this is complete, so we tin can click on the link and run across the new repository on GitHub in a browser. We tin can run across the code on the project, and the iii commits that we made locally are now available on GitHub.

If we go back to IntelliJ Thought, we can see the Git Log has been updated to testify that the remote, origin, is also at this commit. When we expand the Remote branches nosotros can see the master co-operative under the origin remote. This shows us everything has been successfully pushed to GitHub, and that IntelliJ IDEA is besides up to engagement with all the information from the GitHub remote.

Origin and Master Brances

View previous steps in video

In this weblog, nosotros learned 2 ways to create a GitHub repository and local Git repository for an existing IntelliJ Thought projection.

See besides:

  • Prepare a Git repository in IntelliJ Idea
  • Setting upward GitHub in IntelliJ IDEA
  • Using Git Integration
  • Clone a Projection from GitHub (includes video)

gardenerhisiblim.blogspot.com

Source: https://blog.jetbrains.com/idea/2020/11/sharing-your-project-on-github/

0 Response to "How to Upload Intellij Project to Github"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel