Skip to content

git commands

I’ve been using git on and off for version control recently. Here is a list of some of the common basic git commands, along with a simple description of what they do:

git clone repository-url - checkout a repository into the current working directory (creates a local repository)

git checkout -b my-branch create a branch of the current repository and switch to it

git add files - add files to the ‘staging area’ (basically notifies git to prepare files for commit), use git add . to add all files

git commit -m ‘this is a lovely new feature which is complete’ - this will commit the files to the local repository with the message specified by -m

git push - push all changes up to the remote repository

git status - get info about the state of the repository

git merge branch-to-bring-in - merge the specified branch into the current branch

Obviously you can combine the commands to build up various workflow related operations, e.g. if you wish to merge a feature branch into master:
git checkout master; git merge my-branch

For more detailed information on all the git commands available, check out the git man pages here.

Leave a Reply