Git for Perforce users

Getting files and changes from the server

Initial local setup

Perforce

You create a Workspace View. It maps a workspace to one or several Perforce depots, folders and files.

Git

With Git, there is no special setup, you can just clone one single and entire project repository. Project files are stored in your working directory.

$ git clone <repository URL>

Centralized vs Distributed

Perforce

Perforce is a centralized version control system. It means the system database, known as the Perforce depot, is only stored on a central server.

You have local copy of the files you need, but unlike Git you don't have a local copy of the depots.

Most of the Perforce operations are performed on the server, against that remote depots. It means you can't really work offline, unless you use external tools like Perforce Sandbox.

To update your workspace:

$ p4 sync (aka "Get Latest Revision")

REMINDER Checked-out files (ie. opened in a changelist) are not updated.

SVN like Perforce is a centralized (image source: atlassian.com)

Perfoce, like SVN, uses a central repo (image source: atlassian.com)


Git

On the other side, Git is a distributed version control system (DVCS). All the version control information is stored in a .git folder. It makes no difference between your local repository and the remote one you cloned. They both hold this .git folder.

It's up to the team to define one repo as a "reference", for example defining a repo hosted Github as the central one.

As a consequence, most of the Git operations are performed locally. You can work offline.

Fetch a repository to feed your local .git with the latest updates information:

$ git fetch <repository>

The .git folder is updated but your project files remain unchanged. To actually update your project files to another version, you checkout a branch or a commit:

$ git checkout <branch|commit>

WARNING Git checkout is not Perforce checkout. The former is about moving from a version to another, the latter is about opening a file in a changelist.

In the chapter 5 and the next courses you'll learn about merging your work with remote changes. Git provides a shortcut for fetching and merging (or preferably rebasing when using the proper argument or setting) at the same time:

$ git pull

Summary

You learned:

  • perforce workspace view setup vs git clone
  • centralized vs distributed version control system
  • perforce workspace vs git working directory
  • perforce depot vs git repository
  • perforce Get Latest Revision (sync) vs git fetch, checkout and pull
  • perforce checkout is NOT git checkout