DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • Does the OCP Exam Still Make Sense?
  • Incident Response Guide
  • Java String Templates Today
  • You’ve Got Mail… and It’s a SPAM!

Trending

  • Does the OCP Exam Still Make Sense?
  • Incident Response Guide
  • Java String Templates Today
  • You’ve Got Mail… and It’s a SPAM!
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Learning Git: What Is a Commit?

Learning Git: What Is a Commit?

Check out this article to learn more about Git commits.

Jonathan Silva user avatar by
Jonathan Silva
·
Nov. 22, 19 · Presentation
Like (13)
Save
Tweet
Share
9.54K Views

Join the DZone community and get the full member experience.

Join For Free

Person typing on computer

Learn more about Git commits.

Commits are fundamental to Git, but not all developers have a comprehensive understanding of what a commit actually is and how it gets applied to your project.

In short, a commit is a snapshot of your Git repository at one point in time. In this beginner Git tutorial, we will dig into the journey of creating a commit.

You may also like: Top 20 Git Commands With Examples

Git: Working Vs. Staging Directory

To fully understand commits, we need to start by talking about your working directory versus your staging directory.

Your working directory is your active work area, and files created or modified here do not yet affect your project. When you modify, add, delete, or rename a file here, that change is not immediately stored in the repository. It only exists locally in the working directory on your machine.

In order for your changes to be reflected, you must stage them. Once file changes have been staged, they can be saved in the repository by performing a commit.

Each commit becomes a snapshot of your repository from that point in time, and all of your commits will cumulatively from your repo's history.

Git Workflow: Make, Stage, Commit

A typical Git workflow involves:

  • Making changes
  • Staging changes
  • Committing changes

Making File Changes in GitKraken

When you modify, add, delete, or rename any files in your working directory in GitKraken, your Work in Progress (WIP) will display at the top of the graph.

When you click the WIP node, GitKraken shows you a list of the affected files in the Commit Panel on the right side of the UI, along with color-coded icons denoting the change type (modified, added, renamed, deleted).

Staging File Changes in GitKraken

GitKraken makes it quick and easy to stage file changes. Click on your WIP node and navigate to the Commit Panel. Simply hover over a file and click Stage File .

You may also click the file to view the diff, where you can choose to stage individual lines or hunks of the file.

Furthermore, entire files, hunks, or lines can be unstaged or discarded with the click of a button.

Discard all file changes to a given file by right-clicking and selecting Discard Changes, or discard changes to ALL files in your WIP by clicking the trashcan icon at the top of the Commit Panel.

Psst: Don't fear! The handy GitKraken Undo button has your back if file changes are ever discarded by mistake.

Committing Changes in GitKraken

Ready to commit? When you're satisfied with your staged changes, be sure to type a commit summary and description before clicking the button to commit your changes. You can also use the keyboard shortcut Cmd/Ctrl + Enter .

This will transform your WIP node into a commit that can be clicked for future review of the changes made at this specific point in time.

Scroll through the central commit graph in GitKraken to see an overview of your project history, and click through other commits to review snapshots of file changes from other points in time.

If you enjoyed this video, to the GitKraken YouTube channel to stay up-to-date on all of our learning Git tutorials, and check out our Learn Git Center to see an extended list of our educational resources.

Further Reading

[DZone Refcard] Getting Started With Git

Top 20 Git Commands With Examples

Useful Git Commands

Commit (data management) Git

Published at DZone with permission of Jonathan Silva, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Does the OCP Exam Still Make Sense?
  • Incident Response Guide
  • Java String Templates Today
  • You’ve Got Mail… and It’s a SPAM!

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: