Situational guide to Git for new engineers - commit

Situation: You made changes you need to commit to your branch

Making a commit is similar to saving your current work. It is performed on your local branch with optional push to remote to allow for changes to be visible to other developers.

Commit your changes command:

git commit -am "Task ID: Updated ViewModel with new DataProvider"

What does command do

This command -am stands for two things. You are adding all the changes in the current git repository (known as staging) and you are adding a message which is followed up inside the quotation marks.

If this is your only commit to this branch, the message will be automatically used when you create your pull request. Some companies have stricter rules over the message format.

Extra

This command does not push your changes to remote branch. To do that you should run.

git push origin yourBranchName

origin is an alias for remote repository on your system. It’s a default name for it.

Note

Remote is what is known as the main repository which is hosted on a remote server and is considered source of truth for currently active codebase. Anything else that is currently stored on your computer is what is called Local.

Local changes are only visible to you and will not be saved if your computer is lost or damaged, so if you have any important work you don't want to lose, commit your changes and push them to remote as often as you feel comfortable.