AppCode 2019.2 Help

Edit project history

Git allows you to edit your project history. This is useful when you're working on a feature branch and want to clean it up and make it look the way you want before you share it with others. For example, you can edit commit messages, squash together smaller commits related to the same functionality, or split a commit that contains unrelated changes into separate commits, add changes to a previous commit, and so on.

Edit a commit message

If the only thing you need to change is a commit message, you can edit it before you push this commit.

  1. Right-click the commit whose message you want to edit in the Log view and select Reword from the context menu, or press F2.

  2. In the dialog that opens, enter a new commit message and click OK.

Amend the previous commit

Sometimes you may commit too early and forget to add some files, or notice an error in the last commit that you want to fix without creating a separate commit.

You can do this by using the Amend commit option that appends staged changes to the previous commit. As a result, you end up with a single commit instead of two different ones.

  1. Select the changes that you want to add to the previous commit in the Local Changes view and click the Commit button on the toolbar or press ⌘K.

  2. In the Commit Changes dialog, select the Amend commit option on the right before committing your changes.

Amend any earlier commit

If you need to add changes to any earlier commit instead of committing them separately, you can do this by using the fixup or the squash action. Both commands append staged changes to the selected commit, but handle commit messages differently:

  • squash adds the new commit message to the original commit

  • fixup discards the new commit message, leaving only the message from the original commit

  1. Make the changes that you want to append to any earlier commit (they will be visible in the Local Changes view).

  2. In the Log view, right-click the commit that you want to modify with your local changes and select Fixup or Squash Into from the context menu.

  3. Modify the commit message if necessary if you've chosen to squash changes.

  4. Click the arrow on the Commit button and choose Commit and Rebase.

Edit project history by performing interactive rebase

Git allows you to edit project history for the sake of making it linear and meaningful by performing interactive rebase. This allows you to clean up the commits history by altering individual commits, changing their order, squashing commits into one, skipping commits that contain extraneous changes, and so on, before you integrate changes from your feature branch to another branch.

Edit the history of the current branch

AppCode allows you to edit a series of recent commits in the current branch before you apply the changes to a different branch.

  1. In the Log tab of the Version Control tool window select the oldest commit in the series of commits that you want to edit, right-click it and select Interactively Rebase from Here.

    The Interactive Rebase dialog will be displayed containing the list of all commits in the current branch that were made after the selected commit.

  2. If you need to change the order in which the commits should be applied, use the up arrow and down arrow buttons.

  3. Use the Action list to apply the following actions to commits (you can use ⌥↑/⌥↓ to select an action):

    • Pick: applies the selected commit as is.

    • Edit: select to edit the files affected by this commit before applying it. When you select this action, a notification will pop up in the bottom right corner of the IDE window. You can edit the files you want to modify in the editor, and then click Continue in this notification to proceed with the rebase operation.

    • Skip: ignores the selected commit, so these changes won't be applied.

    • Squash: select to combine the selected commit with the previous one. The commit messages of the two commits will be combined, so this action will be reflected in the branch history. Change the order of commits if necessary so that the commit to which you want to append changes is the previous one in the list.

    • Reword: select this option to edit the commit message before applying it.

    • Fixup: select this option to combine the selected commit with the previous one. The commit message of the fixup commit will be discarded, so this change will be invisible in the branch history. Change the order of commits if necessary so that the commit to which you want to append changes is the previous on in the list.

Edit a branch history and integrate it into another branch

AppCode allows you to rebase a branch on top of another branch and edit the source branch history before you apply the changes.

  1. From the main menu select VCS | Git | Rebase.

  2. Select the branch you want to rebase in the Branch field, and the target branch in the Onto field.

  3. In the From field, select the commit starting from which you want to apply the selected branch to the new base.

  4. Make sure the Interactive option is selected, and click Rebase.

    The Interactive Rebase dialog will be displayed containing the list of all commits in the current branch that were made after the selected commit.

  5. If you need to change the order in which the commits should be applied, use the up arrow and down arrow buttons.

  6. Use the Action list to apply the following actions to commits (you can use ⌥↑/⌥↓ to select an action):

    • Pick: applies the selected commit as is.

    • Edit: select to edit the files affected by this commit before applying it. When you select this action, a notification will pop up in the bottom right corner of the IDE window. You can edit the files you want to modify in the editor, and then click Continue in this notification to proceed with the rebase operation.

    • Skip: ignores the selected commit, so these changes won't be applied.

    • Squash: select to combine the selected commit with the previous one. The commit messages of the two commits will be combined, so this action will be reflected in the branch history. Change the order of commits if necessary so that the commit to which you want to append changes is the previous one in the list.

    • Reword: select this option to edit the commit message before applying it.

    • Fixup: select this option to combine the selected commit with the previous one. The commit message of the fixup commit will be discarded, so this change will be invisible in the branch history. Change the order of commits if necessary so that the commit to which you want to append changes is the previous on in the list.

Last modified: 10 October 2019