Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

4. Getting Started with Version Control > Setting Up Git for Your Workflow

Setting Up Git for Your Workflow

For a solo workflow, I’ll typically start with three clones of the same repository:

  • A remote Origin, hosted on GitHub.

  • A local clone of the repository, hosted on my MAMP server.

  • A second remote clone, hosted on a staging server with protected access. The staging server allows clients and collaborators to view the site’s progress as it’s happening, without affecting the production (i.e. live/launch) domain.

All of these repositories are clones of each other, which means they have the same files and data; pushing and pulling syncs the files among them. Most development workflows will typically start this way; as you add collaborators, or move your code from staging to launch, each of these different environments will require its own clone of the main repository. Each collaborator on the team will push and pull to the main repository.

When I first started using Git, I was overwhelmed by trying to figure out how everything worked. After a few times, however, I realized it was relatively easy to get the hang of. The basic workflow is this:

  1. Create an empty repository on GitHub, which will become Origin.

  2. Create a local directory for your installation and copy your files into it.

  3. In Terminal.app, navigate to the new directory and initialize your new Master:

    git init;
  4. Commit your files to Master by typing the following:

    git add -A
    git commit -m "first commit"
  5. Add the remote Origin you just created on GitHub using the command:

    git remote add origin git@github.com/USERNAME/REPOSITORY-NAME.git;
  6. Push the files to GitHub using the following:

    git push origin master

Next, we’ll look at those steps in a bit more detail. Steps 1–4 cover installation, and only need to be done once per computer you’re installing Git on. The rest of the steps will help you set up the workflow for each project.

  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint