-
Notifications
You must be signed in to change notification settings - Fork 0
Committing
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.
- Open a terminal window or command prompt that can run Git (make sure you are in the repo).
- Look at what files have been added, edited, or removed by entering
git status
. - Add files.
- You can choose the files you want to include in the commit using
git add filename
to include specific files. - 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.
- You can choose the files you want to include in the commit using
- 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'
.
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.
- Open a terminal window or command prompt that can run Git (make sure you are in the repo).
- Enter the command
git push origin branch-name
, where branch-name is the name of the branch you're working on.
Your changes will now be available for the rest of the team to view on GitHub.