Reference Guide: Committing Changes
Tags: codenewbie, beginners, webdev, productivity
Published: 2018-12-06 01:38:07

---
cover_image: https://www.summitir.com/wp-content/uploads/2017/02/toolbox-600x450.jpg
title: Reference Guide: Committing Changes
published: true
description: A reference guide series for new web developers.
tags: #codenewbie #beginners #webdev #productivity
---
Welcome back for part three of my reference guide series. 

- Go here for [Part One:](https://dev.to/kymiddleton/reference-guide-common-commands-for-terminal-6no) Reference Guide: Common Commands for Terminal. 
- Go here for [Part two](https://dev.to/kymiddleton/reference-guide-create-a-github-repository-30f8) Create a GitHub Repository


**COMMITTING CHANGES**
When building a new application, a best practice for web development is to code a few lines, test a few lines, then `commit` changes.  The `commit` process is the equivalent of saving changes to a document by clicking the `save` icon. 

To `commit` file changes start by entering the following commands in the terminal:
- `git status`
    * Items that appear in red indicate the files and subsequent changes are not being tracked. These files need to be staged and submitted. 

![git status](https://thepracticaldev.s3.amazonaws.com/i/gocvsfh3v696euu08opq.jpeg)

- `git add –A`
    * This command initiates changes being tracked and the `A` indicates `all` files.  This also transitions the code to be staged. 
- `git status`
    * Repeating this command will show the files previously highlighted in `red` have switched to `green` indicating changes have been tracked, saved and ready to push to the repository.

![git add](https://thepracticaldev.s3.amazonaws.com/i/fql6sf7k92pyu6bxjawm.jpeg)

- `git commit –m “add comment description of changes made”`
    * Staged code is now saved locally with a note to others about the code.  Makes commit messages descriptive and meaningful. 
- `git status`
    * Repeat command to verify all changes have been staged and ready to push to the repository. 
- `git push origin master`
    * Pushing to the master branch is something that should be limited to the first commit of a project repository.
    * Repositories with multiple collaborators should always have the master branch protected with changes being pushed to a branch then pulled into the master by creating a pull request. 

Up next: [Committing changes with branches](https://dev.to/kymiddleton/reference-guide-committing-changes-with-branches-2f8d). 

For the completed Reference Guide Series: 
- [Part One:](https://dev.to/kymiddleton/reference-guide-common-commands-for-terminal-6no) Reference Guide: Common Commands for Terminal. 
- [Part two:](https://dev.to/kymiddleton/reference-guide-create-a-github-repository-30f8) Create a GitHub Repository
- [Part three:](https://dev.to/kymiddleton/reference-guide-committing-changes-43el) Committing Changes
- [Part four:](https://dev.to/kymiddleton/reference-guide-committing-changes-with-branches-2f8d) Committing Changes with Branches
-[Part five:]( https://dev.to/kymiddleton/reference-guide-merge-conflicts-6op) Merge Conflicts
- [Part six:](https://dev.to/kymiddleton/reference-guide-pull-requests-5an9) Pull Requests
- [Part seven:](https://dev.to/kymiddleton/reference-guide-conducting-a-code-review-k6m) Conducting a Code Review
-[Part eight:]( https://dev.to/kymiddleton/reference-guide-complete-and-merge-a-pull-request--12n4) Complete and Merge a Pull Request