Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

An introduction to Git (part 2): Your first Git repository

Parent Feed: 

In An introduction to Git Part 1, you learned a little about what Git and Version control is. You also installed Git on your computer. You are now ready to configure Git and set up your first Git repository. Whether you are using Git for the first time on a Drupal project, or for the 100th time, creating your Git repository always follows the same simple steps.

Git is one of the secrets from my 5 secrets to becoming a Drupal 7 Ninja ebook, and much of the following posts are from this ebook. To learn more about Git and the other secrets, please consider purchasing the ebook or signing up for the 5 secrets email newsletter which will give you more information about the 5 secrets.

Configuring Git from the command line

The first step is to open up your command line. You may want to create an empty test folder somewhere on your computer so you can test a few basic Git commands. I will start with a folder on my desktop called git_test. You will want to make sure you are inside that folder on your command line. If this is your first time using Git, you will likely need to configure your basic Git settings.

Git Command What does it do?
git config --global user.name [name] Configure the username for Git to use for the current logged in user.
git config --global user.email [email_address] Configure the user email address for Git to use for the current logged in user.

You will first want to configure your name.

Git Configuration: Username

Then you will want to configure your email address.

Git Configuration: Email

You should now have your basic Git configuration set up. You are now ready to create your first Git repository.

Creating Your First Git Repository

Git Command What does it do?
git init Creates a Git repository in the current directory.
git init [folder] Creates a new directory and Git repository.

Creating your first Git repository is incredibly simple. Just run the git init command on the command line from within your project folder.

Git Init

If you have not created the git_test folder yet, you can create the empty directory and the Git repository in one step.

Git Init Folder

Either of the above commands will create a new empty Git repository for you to start working with. It does not get much simpler than that. One simple command to Git you started.

Intro to Git Part 2 Summary

You now know how to configure Git from the command line and create your first Git repository. In part 3 of An introduction to Git, you will learn how to add files to your new Git repository.

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web