1. Technology
Send to a Friend via Email
You can opt-out at any time. Please refer to our privacy policy for contact information.

Committing Changes

By

The Git repository tracks the status of all files in your project. However, it doesn't know exactly what you've done until you commit your changes. Committing changes tells Git to look at all the files, find the changes you made as well as any new files and integrate them all into the Git repository. Until you make a commit, any changes made are in limbo and not yet part of the repository.

Each commit requires a commit message. This commit message is very important in creating a log that you can look back on to see what was done to the project. These messages should be short and to the point, and are quite important. So, for example, if you added a new image file and inserted it into an HTML page, your commit message could read "Added logo image and inserted into index.html." Commit messages should be a short description of what was done, anyone interested in the "how" can view a diff.

So, once you've made your changes and are ready to commit, you can issue the command git commit -am "Your message here". Git will then go through, examine all files it tracks, find changes and commit them to the repository. All of these changes will be attached to this commit as well, so in the future you'll be able to see exactly what was done when and why.

©2014 About.com. All rights reserved.