Skip to content
This repository has been archived by the owner on Sep 4, 2022. It is now read-only.

Committing

Lawrence (Drew) Whisenant edited this page Jan 6, 2019 · 2 revisions

You can use git to save "snapshots" of your progress. This is like how you save a document frequently, but you're also able to see the history of the changes you've made.

In git, this is called making a commit. You should make commits as you finish "steps" or "parts" of something. For example, if your task requires you to write three functions, it might be a good idea to make a commit after each function is done.

To complete a commit.

  1. Open a terminal window or command prompt that can run Git (make sure you are in the repo).
  2. Look at what files have been added, edited, or removed by entering git status. Status
  3. Add files.
    1. You can choose the files you want to include in the commit using git add filename to include specific files. Add One
    2. If you need to include all the files you see in the commit, you can do so quickly with git add .. The period means "all files" that have been modified, added, or removed. Add All
  4. After you've added all the files for the commit, make the commit using git commit -m 'Commit message'. The text in the single-quotes is a description of your commit. It should be brief yet descriptive. For example, if your changes were to write a function to take the square root of a number, your message would be 'Add function to take the square root'. Commit

You then repeat these steps until all files have been included in a commit. You'll be able to tell because git status won't have anything else you can include in a git add call.

Once you've made all your commits, you can push them. If committing is like saving your work, pushing is like sharing it. Pushing is what gets the work you've done from your computer back to GitHub.

To complete a push.

  1. Open a terminal window or command prompt that can run Git (make sure you are in the repo).
  2. Enter the command git push origin branch-name, where branch-name is the name of the branch you're working on. Push

Your changes will now be available for the rest of the team to view on GitHub.

Clone this wiki locally