Git for Perforce users

Undoing changes

Changelist file removal and file change discard

Perforce

To remove a file from a pending changelist and/or discard the changes in your workspace, you do:

$ p4 revert -k <files> # keep your workspace unchanged
$ p4 revert <files>

Git

Like removing a file from a Perforce pending changelist, you can remove changes for your stage. It won't touch you working directory by default. But you can reset your local changes to the most recent commit (dangerous! no undo!) with --hard.

$ git reset <files>
$ git reset --hard <files>

NOTE As you can see, while Perforce uses revert, Git uses reset.

Submission undo

Perforce

To undo an already submitted changelist, Perforce offers the Back Out operation. It batches several operations: sync, edit, resolve and submit.


Git

With Git, you can automatically generate a new commit that undoes a specified commit:

$ git revert <commit>

You can then push this commit to any remote branch.

Summary

You learned:

Git reset vs git revert (image source: atlassian.com)

  • perforce revert is NOT git revert but git reset
  • perforce back out vs git revert