How to Upload Project From Intellj to Github

IntelliJ IDEA Videos

Sharing Your Project on GitHub

In this web log, we're going to wait at how to share lawmaking that we've written on our local auto to a repository on GitHub.

This web log postal service covers the same material equally the video with some additional tips and tricks. This provides an easy fashion for people to skim the content chop-chop if they prefer reading to watching, and to requite the reader/watcher code samples and links to additional information.

There are a few ways to utilise IntelliJ IDEA to publish code that nosotros've written on GitHub. In this blog, we volition get over two approaches. The offset is the quickest where you create your local and remote repository in i pace. The second approach is multi-step which can be used when you desire to create a local Git repository for your project separately from publishing any code publicly on GitHub.

Sharing Your Projection on GitHub (Quick Arroyo)

Let's assume nosotros've created an IntelliJ Thought project containing the lawmaking we want to share on GitHub. In this tutorial, we apply a sample Hello World application that we know works because nosotros've seen it run successfully. Information technology'southward not currently fix up with any source command, which we can run across in IntelliJ Idea considering there's no pick for opening a Git window, and if we listing the project's files in the Concluding window, nosotros tin see at that place's no .git folder in the project. We can use IntelliJ IDEA to share this project on GitHub, we tin can go to the VCS menu and select Share project on GitHub .

Share Project on GitHub

If we're not already logged in to GitHub via IntelliJ IDEA, we'll be shown a log in dialog where we can enter our GitHub username and password. This likewise provides the option to log in using a token from GitHub, only fifty-fifty if we don't select that option, if nosotros log in with our username and password here IntelliJ IDEA will generate a GitHub token and use that to log in. If you don't already accept a GitHub account, you can apply the Sign upwardly for GitHub link in IntelliJ IDEA to create ane. If you log in with your username and countersign, and accept ii-factor hallmark enabled for GitHub, IntelliJ IDEA will pop up an additional dialog asking you to input your authentication lawmaking.

Tip: if y'all have multiple GitHub accounts, you lot tin add your GitHub accounts by going to the IDE Preferences -> Version Control -> GitHub. Utilize the add button to add your accounts.

Once we're successfully logged in, IntelliJ IDEA will inquire us what we desire to call the repository that we're about to create on GitHub. This defaults to the project proper name, but nosotros tin pick any proper noun for this repository, as long equally it follows GitHub's guidelines. For my Hullo World project, I will call our repository hullo-world-demo, equally repositories have to have a unique name and I'yard sure there's already a repository called how-do-you-do-globe on my GitHub account. You can make this repository private if you like. I like to make my repositories public, unless there'south a compelling reason to make them individual. You can rename the remote if y'all like, just I will accept the default hither. I will also add together a description too. This isn't mandatory, simply it helps people who desire to understand what the project is for.

Share Project on GitHub Window

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

Add Files for Initial Commit

Everything else looks expert to commit, we'll utilise the default commit message and click Enter to commit information technology.

Under the covers, IntelliJ IDEA is creating a local Git repository for the project and then pushing it to your GitHub profile as a new repository with the details we only entered. When this process is finished, IntelliJ Thought volition popular up a balloon and nosotros tin can click on the link to see the repository in GitHub in a browser. We can encounter 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-stride Approach)

The get-go approach assumed nosotros desire to do everything in a single step. Often nosotros'll want to create a local Git repository for our project well before we want to publish our lawmaking publicly on GitHub.

Let's presume we have a more than complex project than Hello World and that nosotros're nonetheless in the process of writing the lawmaking. We don't want to publish our projection on GitHub but yet, but we practice want to enable source control for information technology equally we want to practice small commits locally while we evolve the code. We ofttimes want to salvage our project's progress each step of the way, for example, once the tests are passing. So, outset, nosotros will create a local Git repository for this IntelliJ Idea project.

We start with a project that is not currently under any source control, so there'south no Git or VCS tool window. To use Git as the version control for an IntelliJ IDEA projection, go to the VCS menu and select Enable Version Control Integration .

Enable Version Control Integration

IntelliJ IDEA supports multiple version control systems, just for this example we want to choose Git. IntelliJ IDEA creates a Git repository in the root directory of the project. We also now have access to the Git tool window. If we open this, we tin see the Console tab which shows the Git commands that have been run and their upshot, or we tin switch to the visual Log tab. Using IntelliJ Idea'south last to list the project'southward files, we tin also run across that we now take a .git binder in the root of our project.

Now we've enabled Git, but nosotros haven't added anything to source control yet. We can run across that our files are shown in crimson, which ways as far as Git is concerned, these are new files that are not nonetheless added to Git, so they're non in source control. Permit's select which files we want to be in source control, and brand our first commit.

Nosotros tin can open up the commit window using Ctrl+G on Windows/Linux or ⌘One thousand on macOS. The tutorial uses the Commit Tool Window, which was added in IntelliJ Idea 2020.1. If yous're still using the old commit dialog, you lot tin switch to the commit tool window in Preferences -> Version Control -> Commit -> Apply not-modal commit interface.

If we open up up the unversioned files listing in this commit window we can see all the files in our projection are listed because none of them have been added to Git however. We probably don't want to add together everything to Git, there are some directories and files, like build output files, that we don't need to put under source command. Seeing all the files in a single list like this might not be helpful, so we could opt to group the files, for example by directory or module.

Group by Directory

With this view I can encounter there are two directories that I don't desire to add to Git, because they're build directories. I do want to add the gradle wrapper directory, my source, and the files in the root of my project. If I open upwardly the .idea folder, I can see all IntelliJ Idea's settings files. Each team will take their own thought of which settings should be saved into source control, if whatsoever. IntelliJ IDEA automatically adds a .gitignore file to this directory with default folders and files to exclude from source control. Nosotros could add other files to this .gitignore file if there 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 description for this commit describing what functionality these changes do. When we commit this, we get a airship proverb this was successful. When we go back to the Git window, the Log tab shows us this commit. Nosotros can meet the files that were inverse in this commit and the commit bulletin. Nosotros can hide the Git window past pressing Alt+nine or ⌘nine again.

View previous steps in video

And so far we've been committing all these changes to our local Git repository. If you open up the Log tab, we can see this project only has local branches, which means all the lawmaking and the commit history is only saved on this local computer. Once you finished setting upwards 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

We recommend not waiting too long to push your projection to GitHub since putting the projection 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 Thought, you lot don't need to re-authenticate. Nosotros need to give the repository a name, this needs to be a unique repository name for the GitHub account information technology will live in. Nosotros tin can rename the remote here if we similar, or exit it as origin. We tin can optionally add a description to help others understand what this project is. When we press Enter or Share, IntelliJ Thought volition create a new repository on GitHub nether the business relationship and push this code to that repository. The airship notification shows when this is complete, then we can click on the link and see the new repository on GitHub in a browser. We can see the code on the project, and the three commits that we made locally are now available on GitHub.

If we go dorsum to IntelliJ IDEA, we tin can encounter the Git Log has been updated to show that the remote, origin, is too at this commit. When we aggrandize the Remote branches we 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 as well up to engagement with all the information from the GitHub remote.

Origin and Master Brances

View previous steps in video

In this web log, we learned two ways to create a GitHub repository and local Git repository for an existing IntelliJ IDEA projection.

See also:

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

pikemathe1997.blogspot.com

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

0 Response to "How to Upload Project From Intellj to Github"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel