18.11.2015 Views

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

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 16 ■ Using Git<br />

Figure 16-1. Creating a new GitHub repository<br />

To create a repository, enter a name in the “Repository name” field, enter a description in the<br />

Description field, and in the “Add .gitignore” select list, choose <strong>Drupal</strong>.<br />

A .gitignore file contains the names of files that you want Git to not track. In the case of <strong>Drupal</strong>, there<br />

are local configuration files such as settings.php that are specific to the local environment where the site<br />

is running. By ignoring settings.php you’ll save the steps of having to modify items such as the database<br />

settings every time you pull from the master repository.<br />

With the repository created on GitHub, the next step is to push your local repository up to GitHub. On<br />

the GitHub page for your repository, you’ll see a clone URL listed in the right column of the page. Copy that<br />

URL, as you are going to need it to push your local repository up to GitHub.<br />

The first step in the process is to set up the GitHub connection on your local machine. From within the<br />

root directory of your <strong>Drupal</strong> 8 site, use the following command to add a reference to your remote GitHub<br />

repository, remembering to paste the clone URL in place of :<br />

git remote add origin <br />

Once you’ve added the remote repository, the next step is to pull down any changes that exist on<br />

GitHub that don’t exist locally, before attempting to push your local repository to GitHub. If you do try to<br />

push changes to GitHub and there are remote changes that don’t exist locally, Git will tell you that your<br />

branch is behind and you have to first pull down the changes. Since we added a .gitignore file on GitHub,<br />

the remote repository does have changes that our local copy of the site does not. So to fix that, use the<br />

following:<br />

git pull origin master<br />

181

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!