Book Image

Version Control with Git and GitHub

By : Alex Magana, Joseph Muli
Book Image

Version Control with Git and GitHub

By: Alex Magana, Joseph Muli

Overview of this book

<p>Introduction to Git and GitHub begins with setting up and configuring Git on your computer along with creating a repository and using it for exercises throughout the book. With the help of multiple activities, you’ll learn concepts that show various stages of a file—from when it is untracked to when it is set for tracking under version control. As you make your way through the chapters, you’ll learn to navigate through the history of a repository, fetch and deliver code to GitHub, and undo code changes. </p><p> </p><p>The first half of the book ends with you learning to work with branches, storing and retrieving changes temporarily, and merging the desired changes into a repository. </p><p> </p><p>In the second half, you’ll learn about forking as part of a collaborative workflow. You’ll also address modularity and duplication through submodules, tracing and rectifying faulty changes, and maintaining repositories. </p><p> </p><p>By the end of this book, you will have learned how to effectively deploy applications using GitHub.</p>
Table of Contents (8 chapters)

Housekeeping

In this subtopic, we will highlight a number of best practices that can be applied toward maintaining a clean and operable repository through the following commands:

  • git clean
  • git gc
  • git prune

git clean

git clean recursively removes untracked files from a working tree. This emphasizes that any file that is not staged to be tracked or reset is rid of, maintaining a versioned only directory. Normally, git clean purges files through a list defined from a .gitignore file, but in special cases, these rules can be ignored and any untracked file is cleared.

Let's complete the following exercise to understand the basic usage of git clean.

Exercise 38: Removing Untracked Files using Git Clean

To remove untracked files from a working tree using git clean, follow these steps:

  1. From the track-it repository, add a new file that collects output data for development, as shown in the following screenshot:
    Figure 5.73: Adding a new file for...