Web Developement
Now Reading
Git Quick Reference
0

Git Quick Reference

by Adrian RandallMay 12, 2015

Git can be one of the most complicated or one of the most beneficial tools in any agency or software development company. However, if you don’t know they most used commands or what they actually do it can be a huge time consumer.

Here are the most commonly used Git Commands which are great to use as a Git Quick Reference guide:

Git Clone

git clone <url_of_git_repository>

What it does:
Copies all the files from the Git Repository to your local environment.

When to use it:
When you’re beginning work on an existing project or setting up a project on another computer.

Example
git clone https://ArcadianDigital@bitbucket.org/ArcadianDigital/XXXX.git

Git Pull

git pull

What it does:
Copies the latest files from the Git Repository to your existing local Git repository.

When to use it:
When you’re working on a project in a team environment and you need to pull other people’s changes to your local repository.

Example
git pull

Git Add

git add . (adds all changed files)

git add <file_path> (adds individual files)

What it does:
This stages (prepares for commit) all or some of your files. This must be done before you are able to commit your changes.

When to use it:
When you have made changes and are ready to commit them and push them to the central repository.

Example
git add .

git add app/controllers/home_controller.rb

Git Commit

git commit -m “Your Commit Message Goes Here”

What it does:
Commits all your staged files which you have staged by using ‘git add’.

When to use it:
When you have staged your changes and want to associate a commit message with your changes. Other tips – Put meaningful messages when you commit changes as you’ll need them later such as “Added header styling for mobile and tablet versions”. If you use a commit message such as “Lots of Stuff” you’ll have no idea where to find errors when you break things, and you will break things!

Example
git commit -m “Your Commit Message Goes Here”

Git Push

git push

What it does:
Copies all of your staged and committed files to the live repository. Once this is done your commit is publicly visible so other people can pull your changed files.

When to use it:
When you have completed and tested a block of work and are ready for others to use your changes. Do not push broked build, otherwise you will learn about ‘git blame’.

Example
git push

While there is obviously a more comprehensive list of git commands, these are the basic ones we use on a daily basis. Do you commonly use other git commands? Like to see others added? Let us know below.

About The Author
Adrian Randall
I'm a digital marketing specialist, love working on digital business and coding on just about anything. I'm the founder of Arcadian Digital and this site shares some of our knowledge and practices.

Leave a Response