Beginning Drupal 8
Todd Tomlinson - Beginning Drupal 8 (The Expert's Voice in Drupal) - 2015
Todd Tomlinson - Beginning Drupal 8 (The Expert's Voice in Drupal) - 2015
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 16 ■ Using Git<br />
Installing Git on OS X<br />
Installing Git on OS X is accomplished through the graphical installer that is available at<br />
http://sourceforge.net/projects/git-osx-installer. This simple-to-use tool provides a quick way<br />
to successfully install Git on your Mac. Download the dmg file, click it to launch the installer, and follow<br />
the instructions. Once it’s installed, test to ensure that Git is installed by launching a terminal window and<br />
typing git at the command prompt and pressing Return. You should see a list of Git commands if Git is<br />
installed correctly. If you do not see a list of commands, visit http://git-scm.com for help.<br />
Installing Git on Windows<br />
To install Git on Windows, download the Git installer exe file from http://msygit.github.io. The Windows<br />
installer installs Git tools that allow you to execute Git commands from a terminal window and installs a<br />
GUI tool for managing your Git repositories. After installing, launch a terminal window, enter git at the<br />
command line, and press Enter. You should see a list of Git commands. If you do not see a list of commands,<br />
visit http://msygit.github.io for help.<br />
Using Git<br />
There are several basic Git commands that will propel you along the path of getting hooked on Git. The first<br />
step in the process of using Git is to set up a Git repository where all of the items you wish to place under<br />
revision control will be stored. Let’s use our <strong>Drupal</strong> 8 installation as our first Git project to place under<br />
source control. Using a terminal window, navigate to the root directory of your <strong>Drupal</strong> 8 installation. In the<br />
terminal window, type git init and press Return.<br />
■■Note<br />
The git init command will return an error message if you have already created a Git repository<br />
for this site.<br />
You should see something similar to this message:<br />
Initialized empty Git repository in /Applications/MAMP/htdocs/drupal8/.git/<br />
If the repository was not successfully created visit the Git website for help on your specific errors.<br />
With the repository created, the next step is to add elements to the repository. Since we haven’t added<br />
any files yet, we will add all files in our <strong>Drupal</strong> 8 directory to Git. To do so, enter the following command:<br />
git add –A.<br />
Make sure you enter the period at the end of the command, as that signifies the current directory. If you<br />
successfully added all the files to your repository, you should be returned to the command prompt without<br />
any messages. If you enter git status at the command prompt and press Return, you should see a long list<br />
of new files that were added to the repository but not yet committed.<br />
The process of committing the files that were just added provides a snapshot that you can roll back to in<br />
the event you make changes in the future that you need to revert to a previous state. How often you add and<br />
commit files is up to you or your project team, the key point being that in order to have the ability to roll back<br />
to a previous point in time, those files must have been added and committed. So let’s commit our <strong>Drupal</strong> 8<br />
files to our Git repository using the following command:<br />
git commit –m "initial commit to the repository"<br />
178