Commit to save work with GitKraken Desktop when changing files. Whether you commit to other things in life is up to you…
Making a commit
To make a commit in GitKraken Desktop, 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.
Commit and push
You can commit and automatically push your changes to the remote. Stage changes and type a commit message to enable the option for commit and push.
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:
Bypass git hooks
There may be times when you want to skip your Git hooks when making a commit. This can be done on a commit-by-commit basis by selecting the Skip git hooks
option.
Note 📝 – Using this option will bypass all hooks that trigger with git commit action.
Commit Templates
Reading the Commit Template
When you open a repository, GitKraken Desktop 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 Desktop.
Creating and Updating the Commit Template
You can create and update a commit template in GitKraken Desktop by visiting Preferences Commit Template.
If a commit template was read from your local git config, any changes you make to the template in GitKraken Desktop 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 Desktop will be written to a file called gkcommittemplate.txt
in your repository’s .git/
directory. GitKraken Desktop 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.
Checking the 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 Desktop:
-
Create the template in GitKraken Desktop – This will create a file called
gkcommittemplate.txt
in your repository’s.git/
directory. -
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 Desktop to a global commit template will cause GitKraken Desktop to create a `gkcommittemplate.txt` file in your local `.git/` directory and point your repository’s git config `commit.template` setting to the `gkcommittemplate.txt` file
Amending commits
GitKraken Desktop 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.
If you only need to update the commit message, select the most recent commit and click in the message box to amend the message.
To accommodate viewing a longer commit description, click on the bar at the the bottom of the message box and drag downwards to dynamically resize the text field.
Select to save your changes or to discard.
Note: Amending commits which are already pushed to a remote are more difficult to apply and would require a force push for the rewrite.
Resetting commits
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 Desktop 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.
Reverting changes
Undo, undo, undo. You can undo many of your actions in GitKraken Desktop 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.
Reverting commits
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.