Commit to save work with GitKraken when changing files. Whether you commit to other things in life is up to you...
Making a commit
To make a commit in GitKraken, select your Work in Progress and to view recent changes on the Commit Panel.
Select the files you wish to stage, and click on any files you wish to review in the diff. To stage all your files, use the keyboard shortcut ⌘ShiftS for Mac or CtrlShiftS for Windows or Linux.
When you’re ready, type your message and hit commit to commit your changes. You can also use this Commit keyboard shortcut ⌘ + Enter for Mac or Ctrl + Enter if you are on Linux or Windows.
The graph updates with your commit, but the undo button or this keyboard shortcut ⌘ + Z for Mac or Ctrl + Z for Windows/Linux can undo a commit made by mistake.
Committing with Co-Authors
To add co-authors to a commit, add a line to your commit description using the following format:
Co-authored-by: INSERT NAME 1 <Email address 1> Co-authored-by: INSERT NAME 2 <Email address 2> ...and so on
The commit panel will then show the co-author in the history for that commit:
Reading the Commit Template
When you open a repository, GitKraken will first check for a commit template set up in your repository's
.git/config. If no commit template is found, it will then check your default (global)
.gitconfig. If no commit template is found there either, then no commit template will be populated in GitKraken.
Creating and Updating the Commit Template
You can create and update a commit template in Gitkraken by visting Preferences Commit Template.
If a commit template was read from your local git config, any changes you make to the template in GitKraken will save to the file specified.
If a commit template was not read from your default
.gitconfig or you are creating a template for the first time, any change you make to the template in GitKraken will be written to a file called
gkcommittemplate.txt in your repository's
.git/ directory. GitKraken will also update your repository's git config
commit.template setting to point to this file. This allows you to make changes to your local commit template without overwriting your global commit template for all of your other repositories.
Apply this template to commit messages option will automatically apply the template to the commit message pane. If this option is not checked, the commit message pane will be blank.
There are three different ways to set up commit templates in GitKraken:
Create the template in GitKraken - This will create a file called
gkcommittemplate.txtin your repository's
Add a repo-specific commit template - Open a terminal in your local repository and run
git config commit.template <path_to_template>
Add a global commit template - Open a terminal window and run
git config --global commit.template <path_to_template>
Note: Any changes made in GitKraken to a global commit template will cause GitKraken to create a
gkcommittemplate.txtfile in your local
.git/directory and point your repository's git config
commit.templatesetting to the
GitKraken allows you to amend a commit message, add additional changes, or both.
To add more changes, amend a commit by clicking on the //WIP node on the graph.
Stage the target files and then be sure to check the Amend box to apply your changes to the previous commit.
If you only need to update the commit message, select the most recent commit and click in the message box to amend the message.
Note: Amending commits which are already pushed to a remote are more difficult to apply and would require a force push for the rewrite.
Git keeps track of your current commit in a file called the HEAD. When resetting a commit, you update the HEAD of your repo to point to the selected commit. GitKraken offers the following reset options:
- Soft - resets the HEAD to the selected commit, but keeps your changes staged and in your WIP directory
- Mixed - resets the HEAD to the selected commit, unstages your changes, but keeps them in your WIP directory
- Hard - resets the HEAD to the selected commit, unstages your changes, and deletes your WIP files
You may also drag and drop a branch onto another to select from the three reset options above or access the reset options from your local repos in the left panel.
Undo, undo, undo. You can undo many of your actions in GitKraken with the Undo icon.
If you're a keyboard fan, you may also enjoy using the keyboard shortcut ⌘ + z for Mac or Ctrl + Z for not-Mac.
If you wish to revert a commit (perhaps Undo is not available), the option is available when right-clicking on a commit node. This will create a new commit to reverse your previous changes.