How to Upload a Program From Intellij to Github

Commit and push changes to Git repository

After you lot've added new files to the Git repository, or modified files that are already under Git version command and you are happy with their current state, you tin can share the results of your work. This involves committing them locally to record the snapshot of your repository to the project history, and so pushing them to the remote repository so that they get bachelor to others.

Set your Git username

Git needs to know your username to associate commits with an identity. If you accept not ready your username, IntelliJ Thought will prompt you lot to specify it when you get-go endeavor to commit changes.

  • Open up the Final and execute one of the post-obit commands:

    • To set a name for every Git repository on your machine, use $ git config --global user.name "John Smith"

    • To fix a proper name for a single repository, utilise $ git config user.name "John Smith"

Commit changes locally

  1. Open the vertical Commit tool window Alt+0 located on the left:

    Commit tool window
  2. Every bit your changes are gear up to be committed, select the corresponding files or an unabridged changelist.

    If yous press Ctrl+1000, the entire agile changelist will be selected.

    You lot can also select files under the Unversioned Files node — IntelliJ IDEA will stage and commit these files in one step.

  3. If you want to append local changes to the latest commit instead of creating a separate commit, select the Meliorate selection.

  4. Enter the commit message. Yous tin click Commit message history button to choose from the list of recent commit messages.

    You can also edit the commit message afterward before yous've pushed the commit.

  5. If you lot need to perform pre-commit checks, upload files to a server after the commit, or commit with advanced options, click the Gear icon:

    advanced commit options popup

    The post-obit options are available:

    • Author: if y'all are committing changes made by another person, you tin specify the author of these changes.

    • Sign-off commit: select if you want to sign off your commit to certify that the changes you are nearly to check in accept been fabricated by y'all, or that you have the responsibility for the code y'all're committing.

      When this option is enabled, the following line is automatically added at the end of the commit message: Signed off by: <username>

    • In the Earlier Commit area, select the actions y'all want IntelliJ Thought to perform earlier committing the selected files to the local repository.

      The post-obit options are available:

      • Reformat code: perform code formatting according to the Project Code Mode settings.

      • Rearrange code: rearrange your code co-ordinate to the arrangement rules preferences.

      • Optimize imports: remove redundant import statements.

      • Analyze code: clarify modified files before committing them. Click Cull profile to select an inspection profile from which the IDE volition run inspections.

      • Bank check TODO (<filter proper name>): Review the TODO items matching the specified filter. Click Configure to choose an existing TODO filter, or open the TODO settings page and define a new filter to be applied.

      • Cleanup: batch-apply quick-fixes from lawmaking cleanup inspections. Click Cull contour to select a profile from which the IDE volition run inspections.

      • Run Tests: run tests as pre-commit checks. Click Choose configuration near Run Tests and select which configuration y'all want to run.

      • Update copyright: add or update a copyright notice according to the selected copyright profile - scope combination.

    • In the After Commit area, you tin select the server admission configuration or a server grouping to use for uploading the committed files to a local or remote host, a mounted disk, or a directory. Meet Deploy your awarding for details.

      The following options are available:

      • Run tool: select the external tool that you want IntelliJ Idea to launch after the selected changes have been committed. You lot can select a tool from the list, or click the Browse button the Browse button and configure an external tool in the External Tools dialog that opens.

      • Upload files to: select the server access configuration or a server group to utilise for uploading the committed files to a local or remote host, a mounted disk, or a directory.

        • To suppress uploading, choose None.

        • To add a server configuration to the list, click the Browse button and fill up in the required fields in the Add together Server dialog that opens.

        The list is just bachelor if the FTP/SFTP Connectivity plugin is enabled.

      • Always use selected server or group of servers: always upload files to the selected server or a server group.

        The checkbox is only available if the FTP/SFTP Connectivity plugin is enabled.

  6. When you're fix, click Commit or Commit and Push (Ctrl+Alt+K) to push the changes to the remote repository immediately after the commit. You volition be able to review the current commit too equally all other commits before they are pushed to the remote.

Commit part of a file

Sometimes when you lot make changes that are related to a specific job, y'all also utilize other unrelated code modifications that touch the same file. Including all such changes into 1 commit may non be a good option, since it would be more hard to review, revert, cherry-choice them, and and then on.

IntelliJ Idea lets y'all commit such changes separately in one of the following means:

  • select modified code chunks, that you want to include in a commit right in the Commit Changes dialog and exit other changes awaiting so that you lot tin commit them after.

  • put unlike code chunks into different changelists on the fly, when you edit lawmaking, then commit these changelists separately.

Select chunks you want to commit

  1. Open the vertical Commit tool window Alt+0.

  2. To brandish the differences between the repository version and the local version of the selected file, in the Commit tool window Alt+0, click the Diff icon on the toolbar or press Ctrl+D.

  3. Select the checkbox next to each chunk of modified or newly added code that you want to commit, and go out other changes unselected:

    Partial commit dialog
  4. Click Commit. Unselected changes will stay in the current changelist, so that you tin can commit them separately.

Put changes into different changelists

  1. When you make a change to a file in the editor, click the respective change marking in the gutter.

  2. In the toolbar that appears, select the target changelist for the modified code chunk (or create a new changelist):

    Partial commit changelists
  3. Commit each changelist separately.

Employ the Git staging area to commit changes

If you are more than used to the concept of staging changes for commit instead of using changelists where modified files are staged automatically, select the Enable staging area option on the Version Control | Git page of the IDE settings Ctrl+Alt+S.

The Commit tool window will now look every bit follows:

Git staging area

Using the staging expanse allows you to easily commit changes to the same file separately (including overlapping changes), and run across which changes are already staged without switching focus from the editor.

Stage changes for commit

  1. Exercise i of the post-obit:

    • To stage an unabridged file, in the Commit tool window Alt+0, select this file and click the Add button on the correct next to information technology or printing Ctrl+Alt+A.

      Stage from the Commit tool window
    • To stage a specific chunk inside a file, in the editor click the change marker in the gutter next to the modified clamper and click Stage.

      Stage change from the editor

      Staged changes (including changes staged from exterior IntelliJ IDEA) are marked with a edge-shaped change mark in the editor:

      Gutter marker for staged changes
    • To phase granular changes similar a single line instead of a code chunk, or fifty-fifty ane of a number of changes to a single line, in the Commit tool window Alt+0, select the file containing the change and choose Compare Caput, Staged and Local Versions from the context menu.

      This will open up a three-way diff viewer where the left pane shows the repository version, the right pane shows the local version, and the central pane is a fully-functional editor where you can make the changes you desire to stage.

      Stage changes interactively
  2. When prepare, commit the changes equally described in Commit changes locally.

Push changes to a remote repository

Before pushing your changes, sync with the remote and make certain your local copy of the repository is up-to-date to avoid conflicts.

IntelliJ Idea allows you to upload changes from whatsoever branch to its tracked branch or to any other remote branch.

  1. Do one of the following:

    • To push changes from the current branch press Ctrl+Shift+One thousand or choose from the main menu.

    • To push changes from any local branch that has a remote, select this branch in the Branches popup and choose Push button from the list of actions.

    The Push button Commits dialog opens showing all Git repositories (for multi-repository projects) and listing all commits fabricated in the current branch in each repository since the last push.

    If you take a project that uses multiple repositories that are not controlled synchronously, only the current repository is selected by default (for details on how to enable synchronous repositories control, refer to Version Control Settings: Git).

  2. If there are no remotes in the repository, the Define remote link appears. Click this link and specify the remote proper noun and URL in the dialog that opens. It volition be saved and you can edit it later via (for details, see Add a remote repository).

  3. If you want to change the target co-operative where you want to button, you lot can click the branch name. The label turns into a text field where you can blazon an existing branch name, or create a new branch. You tin also click the Edit all targets link in the lesser-right corner to edit all branch names simultaneously.

    Note that you cannot modify the local branch: the current branch for each selected repository volition be pushed.

  4. If y'all have some commits you've made merely not yet want to push to a remote co-operative, in the Log tab of the Git tool window select the terminal commit you want to button and cull Push button All upwards to Here… option from the list of deportment.

    The Push Commits dialog opens showing all commits up to the selected commit hash.

  5. If you lot want to preview changes before pushing them, select the required commit. The right-hand pane shows the changes included in the selected commit. You lot tin can use the toolbar buttons to examine the commit details.

    If the writer of a commit is different from the electric current user, this commit is marked with an asterisk.

  6. Click the Push button when prepare and select which functioning you desire to perform from the drop-downward carte: Push button or Forcefulness push (equivalent to push --force-with-charter).

    These choice options are only bachelor if the current branch is non listed in the Protected branches field (see Version Control Settings: Git), otherwise, you can only perform the button performance.

Update your working copy if button is rejected

If push button is rejected because your working re-create is outdated, IntelliJ Thought displays the Push Rejected dialog, provided that the Auto-update if push of the current branch was rejected option in the Git settings page of the Settings/Preferences dialog is non selected. Do the post-obit:

  1. If your project uses several Git repositories, specify which of them you desire to update. If y'all want to update all repositories, no matter whether push button was rejected for them or not, select the Update all repositories option. If this option is cleared, only the afflicted repositories will be updated.

  2. If you desire IntelliJ IDEA to apply the update procedure silently the next time push is rejected using the update method you cull in this dialog, select the Call up the update method choice and silently update in the futurity option.

    Later you leave this dialog, the Auto-update if push of the electric current branch was rejected checkbox in the Git settings folio of the Settings/Preferences dialog will be selected, and the applied update method will go the default one.

    To change the update strategy, deselect this option to invoke the Push Rejected dialog the next fourth dimension push of the electric current co-operative is rejected, use a dissimilar update procedure, and select the Remember the update method choice option once more.

  3. Select the update method (rebase or merge) past clicking the Rebase or Merge button respectively.

When do I need to use force push?

When you run push, Git volition reject to consummate the operation if the remote repository has changes that you are missing and that you are going to overwrite with your local copy of the repository. Normally, you need to perform pull to synchronize with the remote earlier you update it with your changes.

The --force push command disables this cheque and lets you overwrite the remote repository, thus erasing its history and causing information loss. Under the hood, when yous cull to force push button, IntelliJ Thought performs the push --force-with-charter operation which is a safer option that helps you ensure yous do non overwrite someone else'south commits (see git push for more details on the push options).

A possible situation when you lot may all the same need to perform --force push is when you rebase a pushed branch and then want to button it to the remote server. In this case, when you try to push, Git will reject your changes because the remote ref is non an ancestor of the local ref. If you perform pull in this state of affairs, you will end up with two copies of the branch which you then need to merge.

Concluding modified: 19 March 2022

carveridowed.blogspot.com

Source: https://www.jetbrains.com/help/idea/commit-and-push-changes.html

0 Response to "How to Upload a Program From Intellij to Github"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel