Welcome back for part three of my reference guide series.
- Go here for Part One: Reference Guide: Common Commands for Terminal.
- Go here for Part two 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 add –A
- This command initiates changes being tracked and the
A
indicatesall
files. This also transitions the code to be staged.
- This command initiates changes being tracked and the
-
git status
- Repeating this command will show the files previously highlighted in
red
have switched togreen
indicating changes have been tracked, saved and ready to push to the repository.
- Repeating this command will show the files previously highlighted in
-
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.
For the completed Reference Guide Series:
- Part One: Reference Guide: Common Commands for Terminal.
- Part two: Create a GitHub Repository
- Part three: Committing Changes
- Part four: Committing Changes with Branches -Part five: Merge Conflicts
- Part six: Pull Requests
- Part seven: Conducting a Code Review -Part eight: Complete and Merge a Pull Request
Top comments (0)