I am a Git user trying to learn Perforce.
I'm sorry.
How can this be performed using Perforce?
I'm a better Git user than I am a Perforce user, so correct me if anything appears wrong. I highly recommend reading the man pages and a tutorial.
It "can't" be, at least not quite the way Git does it.
In git
, when you create a branch, you're branching the entire state of the repository. Perforce does not support this, rather, it's "branching" is more per-file: i.e., you branch file A into file B, at which point file B contains a back reference to file A saying "I came from here." This back reference can then be used to determine a common ancestor for merging purposes. My understanding, however, is that these back references are per-file, and you are free to integrate (merge) any file into any other. (Compare to git, where "Parent commit" is your back-reference, but is on a whole-repository scale.)
You can branch entire sets of files using p4 integrate
, using the typical Perforce syntax (e.g., //depot/some/path/...
). Typically, you'd branch a whole directory to a whole other directory, such as //depot/main/my_project
into //depot/release-1.0/my_project
, or something similar. Perforce, as far as I know, doesn't really care about the paths: it just "branches" files from one location to another. Any pattern or sanity in the paths is up to you.
Additionally, you can use p4 branch
to create "branch specifications", which are basically a way to record the source set of files and their destinations, to make branching easier. (If you take the release example, you may want to eventually merge back changes, or merge further changes into the release, etc.)
Both times I've worked with Perforce, branches were a beast of a different nature than in Git, and there's a bit of a culture difference here. Branches were comparatively rare. (I only saw them used for releases, ever.) We did not use them for feature branches, except perhaps the largest of features; compare to git
, where to me a "feature branch" is usually "it took >1 commit".