Starting with an Unversioned Project
Learn how to initialize your repository and how to make your first commit — after deciding which files in your Working Copy should be ignored!
Starting with an Unversioned Project featured image

Starting with an Unversioned Project

Let's start with an existing project that is not yet under version control.

Activate Tower's Repositories view by clicking on the corresponding button right below the toolbar.

Now, click the "Create" button on the right and select your project's root folder.

When you confirm the "Create" dialog, Git will create a hidden ".git" directory in that folder (which you'll only see if you've explicitly configured your file browser to show hidden files - which isn't necessary for this course).

This little ".git" folder is our new, empty Git repository. Please mind the word "empty": Git did not add the current files of your working copy as something like an "initial version". The repository contains not a single version of your project, yet.

Glossary

Working Copy

The root folder of your project is often called the "working copy" (or "working directory"). It's the directory on your local computer that contains your project's files.
You can always ask the version control system to populate your working copy with any version of your project. But you always only have one working copy with one specific version on your disk - not multiple in parallel.

You'll see that our new repository was added in Tower's sidebar. Open the repository for working by double-clicking it.

Ignoring Files

Typically, in every project and on every platform, there are a couple of files that you don't want to be version controlled: e.g., those pesky ".DS_Store" files on Mac OS aren't worth versioning. In other projects, you might have build or cache files that make no sense in a version control system. You'll have to decide yourself which files you don't want to include.

Note

Which Files Should I Ignore?

As a simple rule of thumb you'll most likely want to ignore files that were created automatically (as a "by-product"): temporary files, logs, cache files...

Other examples for excluded files range from compiled sources to files that contain passwords or personal configurations.

A helpful compilation of ignore rules for different projects and platforms can be found here: github.com/github/gitignore

The list of files to ignore is kept in a simple file called ".gitignore" in the root folder of your project. It's highly recommended to define this list at the very beginning of your project - before making your first commit. Because once files are committed, you'll have to jump through some hoops to get them out of version control, again.

Now, let's get going: activate the Settings view in Tower's sidebar. Select the "Ignores" tab on the top right and click "Open in Editor" to have the .gitignore file created and opened for you.

On a Mac, for example, you'll want to make sure it contains at least the following line:

.DS_Store

If there are other files you want to ignore, simply add a line for each one. Defining these rules can get quite complex. Therefore, to keep things simple, I'll list the most useful patterns which you can easily adapt to your own needs:

  • Ignore one specific file: Provide the full path to the file, seen from the root folder of your project.
    path/to/file.ext
  • Ignore all files with a certain name (anywhere in the project): Just write down the file's name, without giving a path.
    filename.ext
  • Ignore all files of a certain type (anywhere in the project):
    *.ext
  • Ignore all files in a certain folder:
    path/to/folder/*

Making Your First Commit

With some ignore rules in place, it's time to make our initial commit for this project. We'll go into great detail about the whole process of committing a little later in this book. For now, simply follow these steps:

  1. Activate the "Working Copy" view in the sidebar.
  2. Click the "Stage All" button.
  3. Enter a short commit message (like "Initial commit") as a "Commit Subject".
  4. Click the "Commit" button to confirm.

About Us

As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.

Just like with Tower, our mission with this platform is to help people become better professionals.

That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.