How to commit and push in Git

John John (304)
2 minutes

This guide will show you how to properly commit and push your work in Git. It is assumed that you have Git installed and that you're currently in a clean master branch.

Posted in these interests:
h/www5 guides
h/webdev60 guides
h/git16 guides

With a clean master branch checked out, you can create a task branch by typing:

git checkout -b task_branch
where the task_branch is the name of the branch you want to create. By using the -b option it will both create a new branch and check it out.

As your are doing work you can commit regularly, and you must also commit when you are finished with your task. You can commit by typing:

git commit -am "commit message"
and you should leave a detailed commit message describing the changes you made.

Now that you've finished your task you need to checkout master and merge your work. To checkout master simply type:

git checkout master
and to merge your task branch type:
git merge task_branch
where task_branch is the name of your branch.

Now that your work is merged, go ahead and push the master branch by typing:

git push origin master

John John (304)

There are some fundamental git commands that you will use frequently that are hard to work into a "how-to" guide. Here are some basic git commands and how to use them. These are in no specific order.