Git for Perforce users

Working on a new feature

File edition and addition

Perforce and Git handle file edition and change management in a different order.

Perforce

  • 1) With Perforce, you first have to checkout the files you want to work on. In particular, it gives write permissions and open them in a pending changelist.
$ p4 edit (aka "Checkout")
  • 2) Only after, you can edit your files.

Moreover, to have to add new files in a changelist:

$ p4 add

NOTE You may use Perforce more like Git (see below) by setting the "allwrite" option to your workspace. In this case, you'll reconcile your changes and use a safe sync (p4 sync -s or the alias p4 status).


Git

(image source: atlassian.com)

  • 1) Unlike Perforce, you just start editing any files you want

  • 2) At any moment, you can stage a change related to a feature. The git staging area fulfills the same purpose as a Perforce pending changelist. They are both places where you group changes together before submission. You'll learn much more about staging in the next courses.

$ git add <files or lines of code>

New files in your working directory are seen as untracked by git. You add them the same way.

Summary

You learned:

  • Perforce checkout vs git add
  • Perforce pending changelist vs git staging area
  • The edition workflow has a different order