commit label [name]
Assigns a label to a configuration commit for easier identification and rollback.
Overview
The 'commit label [name]' command in Cisco IOS-XR is used to assign a human-readable label to a configuration commit. This label can be used later to identify the commit for rollback or audit purposes. The concept behind this command is to provide a way to tag configuration changes with meaningful identifiers, such as change request numbers, bug IDs, or descriptive names. This is particularly useful in large networks where multiple engineers make changes, and tracking changes is critical for troubleshooting and compliance. On IOS-XR, commits are atomic and versioned; labels add an extra layer of identification. The command is typically used in configuration mode after making changes. It fits into troubleshooting workflows by allowing engineers to quickly identify and rollback to a specific labeled commit if a change causes issues. Labels are stored in the commit database and can be viewed with 'show configuration commit list'. They are persistent across reloads and can be used with the 'rollback' command to revert to that commit. Unlike comments, labels are unique and can be used as a direct reference.
commit label [name]When to Use This Command
- Labeling a commit before a major change to easily rollback if needed.
- Tracking configuration changes with descriptive labels for audit purposes.
- Collaborating with multiple engineers by labeling commits with change request IDs.
- Automating rollback scripts that reference specific commit labels.
Parameters
| Parameter | Syntax | Description |
|---|---|---|
| name | WORD | A unique alphanumeric string (up to 64 characters) that identifies the commit. Must be unique among all commit labels. If the label contains spaces, it must be enclosed in double quotes. |
Command Examples
Label a commit with a descriptive name
commit label pre-bgp-changeCommit complete. Commit label 'pre-bgp-change' applied.
The commit is saved with the label 'pre-bgp-change', which can be used later with 'rollback' or 'show configuration commit list'.
Label a commit with a change request ID
commit label CR-12345Commit complete. Commit label 'CR-12345' applied.
The label 'CR-12345' is associated with this commit, making it easy to reference in change management systems.
Understanding the Output
The output of 'commit label [name]' is minimal. It confirms that the commit was successful and that the label has been applied. The label is stored in the commit database and can be viewed with 'show configuration commit list' or used with 'rollback' commands. A healthy output shows 'Commit complete' and the label name. If there are errors, such as a duplicate label, the command will fail with an error message. The label must be unique; if a label already exists, the commit will be rejected.
Configuration Scenarios
Labeling a commit before a risky change
An engineer is about to apply a new BGP policy that could affect routing. They want to label the current commit so they can easily rollback if needed.
Topology
Single router with BGP peers.Steps
- 1.Enter configuration mode.
- 2.Apply the new BGP policy.
- 3.Commit with a label 'pre-bgp-policy-change'.
- 4.Verify the commit label is stored.
! router bgp 65000 neighbor 10.1.1.1 route-policy NEW-POLICY in ! commit label pre-bgp-policy-change
Verify: Use 'show configuration commit list' to see the label.
Watch out: If the label already exists, the commit will fail. Ensure uniqueness.
Troubleshooting with This Command
When troubleshooting configuration issues on Cisco IOS-XR, the 'commit label' command is primarily used for rollback purposes. If a change causes problems, you can use 'rollback to label <label>' to revert. To view all commits and their labels, use 'show configuration commit list'. If you cannot remember the label, you can use 'show configuration commit changes <commit-id>' to see what changed. Labels are especially useful when multiple engineers are working on the same device; each can label their commits with their initials or ticket numbers. If a commit fails due to a duplicate label, you must choose a different label or remove the existing one with 'rollback to label <label>' (which deletes later commits) or use 'commit replace' carefully. Labels are not displayed in the running configuration; they are only in the commit database. To see the label associated with the current running configuration, use 'show configuration commit list last 1'. For automation, labels can be used in scripts to rollback to a known good state. Always verify the label exists before attempting a rollback.
CCNA Exam Tips
Remember that labels are optional but must be unique per commit.
Know that 'commit label' can be combined with other commit options like 'comment' or 'confirmed'.
Understand that labels are stored in the commit database and persist across reloads.
Common Mistakes
Using a label that already exists, causing the commit to fail.
Forgetting to use quotes if the label contains spaces (e.g., 'commit label "my label"').
Assuming labels are case-sensitive; they are case-sensitive on IOS-XR.
Platform Notes
On Cisco IOS-XR, the 'commit label' command is part of the commit model that is distinct from Cisco IOS. In IOS, configuration changes are applied immediately, and there is no commit concept. IOS-XR requires explicit commits, and labels are an optional feature. The equivalent in IOS would be to use 'archive' or 'configure replace' with a file name. On other platforms like Juniper Junos, the 'commit' command can also take a comment, but labels are not directly supported; instead, you can use 'commit comment' and then reference the commit ID. IOS-XR labels are case-sensitive and must be unique. In IOS-XR versions prior to 6.0, labels were not supported; they were introduced later. When migrating from IOS, engineers should be aware that labels provide a more robust way to manage configuration changes. The 'commit label' command can be combined with 'commit confirmed' to automatically rollback if not confirmed, which is useful for remote changes.
Practice for the CCNA 200-301
Test your knowledge with hundreds of CCNA practice questions covering all exam domains.
Practice CCNA Questions