Overview
Committing changes is at the heart of Git workflows. GitHub Desktop provides an intuitive interface for reviewing changes, staging files, and creating meaningful commits.Visual Diff
See exactly what changed with syntax-highlighted diffs
Selective Staging
Stage individual files or specific line changes
Commit Messages
Write descriptive commit messages with title and description
Git Hooks
Support for pre-commit, commit-msg, and post-commit hooks
Understanding the Changes View
Changes List
The left sidebar shows all modified files in your working directory:- Checkboxes: Select which files to include in the commit
- File Icons: Visual indicators for file status
- Green
+: New file (untracked) - Yellow
M: Modified file - Red
-: Deleted file - Blue
R: Renamed file - Purple
C: Copied file - Gray
?: Untracked file
- Green
Diff Viewer
The main panel displays the diff for the selected file:- Line-by-line changes: See exactly what was added, removed, or modified
- Syntax highlighting: Code appears with proper syntax coloring
- Split/unified view: Toggle between side-by-side and unified diff views
- Expand context: Click to show more surrounding lines
Creating a Commit
Stage Files
Select which files to include:
- Check individual files to stage them
- Click Select All to stage all changes
- Uncheck files you want to exclude
Write Commit Message
In the commit message box at the bottom:
- Summary: Brief description (required, ~50 characters)
- Description: Detailed explanation (optional, supports markdown)
GitHub Desktop clears the staging area before each commit, ensuring your commits reflect the exact state shown in the diff viewer.
Commit Implementation
GitHub Desktop’s commit implementation includes several advanced features:Partial Commits (Staging Specific Lines)
Stage specific line changes within a file:Writing Good Commit Messages
Message Structure
A well-formatted commit message consists of:-
Summary Line (required):
- Brief description of changes
- ~50 characters (hard limit: 72)
- Imperative mood: “Add feature” not “Added feature”
- No period at the end
-
Description (optional):
- Detailed explanation of what and why
- Supports markdown formatting
- Wrap at 72 characters per line
- Include context, motivation, and implementation notes
Examples
Commit Message Tips
Be Specific
“Fix login bug” → “Fix session timeout in OAuth flow”
Explain Why
Include the reason for the change, not just what changed
Reference Issues
Link to issues with “Fixes #123” or “Relates to #456”
Use Imperative
“Add feature” not “Added feature” or “Adds feature”
Amending Commits
Modify your most recent commit:Git Hooks Support
GitHub Desktop fully supports Git hooks that run during the commit process:Supported Hooks
pre-commit
pre-commit
Runs before creating the commit. Common uses:
- Linting code
- Running tests
- Checking code formatting
prepare-commit-msg
prepare-commit-msg
Runs after the default message is created but before the editor is shown. Used to:
- Auto-generate commit messages
- Add ticket numbers
- Include template text
commit-msg
commit-msg
Validates the commit message. Used to:
- Enforce commit message format
- Require issue references
- Check message length
post-commit
post-commit
Runs after the commit is created. Used for:
- Notifications
- Triggering CI/CD
- Logging
Hook Output
When a hook runs, GitHub Desktop:- Shows progress indicator
- Displays hook output in real-time
- Allows aborting long-running hooks
- Shows error messages if hooks fail
Co-authoring Commits
Add co-authors to commits for pair programming:
Co-authored commits appear on both authors’ GitHub profiles.
Merge Commits
When completing a merge with conflicts, GitHub Desktop creates a merge commit:Merge commits automatically use the message generated by Git, which includes information about the merged branches.
Discarding Changes
Revert uncommitted changes:Discard All Changes
Discard Specific Files
- Right-click a file > Discard changes
- Or select multiple files and right-click > Discard changes
Viewing Commit History
Switch to the History tab to see previous commits:- Chronological list of commits
- Commit message, author, and timestamp
- Changed files for each commit
- Visual representation of branch structure
Commit Warnings
GitHub Desktop displays warnings for:- Large commits: More than 100 files changed
- Large files: Files over 100MB
- Protected files: System files or sensitive data
- Unmerged files: Files with unresolved conflicts
Best Practices
- One Logical Change per Commit: Each commit should represent a single, complete change
- Test Before Committing: Ensure your code works before creating a commit
- Review Your Diff: Always check what you’re committing in the diff viewer
- Write Meaningful Messages: Future you (and your teammates) will thank you
- Use Descriptive Summaries: Make it easy to understand commits at a glance
- Commit Related Changes Together: Don’t mix unrelated changes in a single commit
Keyboard Shortcuts
| Action | Windows/Linux | macOS |
|---|---|---|
| Commit | Ctrl+Enter | Cmd+Enter |
| Select all files | Ctrl+A | Cmd+A |
| Deselect all | Ctrl+Shift+A | Cmd+Shift+A |
| Show in diff | Enter | Enter |
| Toggle file selection | Space | Space |
Troubleshooting
Commit Button Disabled
Commit Button Disabled
Hook Failures
Hook Failures
If a pre-commit or commit-msg hook fails:
- Read the error message in the hook output dialog
- Fix the issues identified by the hook
- Try committing again
- Use
--no-verifyflag (Repository menu) to skip hooks if necessary
Cannot Amend Commit
Cannot Amend Commit
You cannot amend if:
- There are no commits in the repository
- The commit has been pushed to a protected branch
- You’re in a rebase, merge, or cherry-pick state