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

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 />

After executing the commit command, you should see a long list of messages that new nodes were<br />

created in your Git repository, one message per file committed. If you execute the git status command,<br />

you should see that everything is up to date:<br />

# On branch master<br />

nothing to commit, working directory clean<br />

At this point we’ve committed the files and now have the ability to revert files to the state they were in<br />

when we committed them a few moments ago. The next step in the process is adding changes to files and<br />

committing those changes. Let’s make a change to an existing file and add a new file to see how Git responds<br />

to both situations. First, create a new file in your sites/default/files directory. For demonstration purposes,<br />

create a new file named test.txt with a few lines of information so we can see Git in action. After creating the<br />

file, execute git status to verify that Git recognized the new file. You should see output similar to<br />

# On branch master<br />

# Untracked files:<br />

# (use "git add ..." to include in what will be committed)<br />

#<br />

# test.txt<br />

So let’s follow the instruction and use git add test.txt to add the file to Git. After adding the file, use<br />

git status to check to see that the file was added. You should see output similar to<br />

# On branch master<br />

# Changes to be committed:<br />

# (use "git reset HEAD ..." to unstage)<br />

#<br />

# new file: test.txt<br />

#<br />

where new file: was prepended to the file name to indicate that Git is now tracking that file.<br />

Let’s commit the new file to the repository so we have the ability to revert to the current state in the<br />

future. Use the following to commit the file:<br />

git commit –m "committing the initial version of test.txt to the repository"<br />

After committing, run git status to see that everything is committed. You should see the message<br />

stating that there is nothing to commit.<br />

Let’s now change the test.txt file by adding more information to it to see if Git sees the changes to the<br />

file. After adding text to your file, run git status. You should see a message similar to<br />

# On branch master<br />

# Changes not staged for commit:<br />

# (use "git add ..." to update what will be committed)<br />

# (use "git checkout -- ..." to discard changes in working directory)<br />

#<br />

# modified: test.txt<br />

#<br />

179

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

Saved successfully!

Ooh no, something went wrong!