Reputation: 19333
I come from a git background, and have been using it for years. Prior to that, I used subversion for several years, and had to occasionally use CVS.
I'm starting on a large perforce project and want to create a feature branch so that:
With a tool like git
, this was pretty easy:
git checkout -b my_branch
# make some edits
git add -u
git commit
git push
How do I accomplish the same (more or less) in perforce, using the command-line interface? Apparently I have to first use p4 branch
to "create a branch spec", and then use p4 integrate
to "open files for merging or branching", but couldn't find any concrete examples that make sense.
Thank you.
Upvotes: 0
Views: 591
Reputation: 1023
If you are unable to use DVCS and your site uses streams, have a look at Task Streams: https://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.streams.html#streams.types.task
You can use these to work on bug-fixes or features and they are semi-private.
Once you are happy with the work it can be merged back to the main stream/branch.
They even work with non-streams depots.b
Upvotes: 1
Reputation: 71454
If you want something that's comparable to the git experience you probably want to be using Perforce's DVCS mode: https://www.perforce.com/perforce/r15.2/manuals/dvcs/
So, assuming you're doing this in your own local server, the flow is like this:
p4 fetch
p4 switch -c my_branch
# make some edits
p4 submit -d "Made my edits."
p4 switch main
p4 fetch
p4 merge --from my_branch
p4 resolve -am
p4 submit -d "Merged my edits into main."
p4 push
If you're doing this directly on a shared server that uses streams, you can skip the fetching and pushing part since every submit is already going straight to the "remote" (although I'll assume the allwrite/auto-reconcile feature that mimics "git commit -a" isn't on in that case, so you'll be using "p4 edit" to open your files for edit):
p4 switch -c my_branch
p4 edit (your files)
# make some edits
p4 submit -d "Made my edits."
p4 switch main
p4 merge --from my_branch
p4 resolve -am
p4 submit -d "Merged my edits into main."
If you're doing this on a shared server that doesn't use streams (i.e. "classic Perforce") then it's:
p4 integ //depot/main/... //depot/my_branch/...
cd my_branch
p4 submit -d "Created my branch."
p4 edit (your files)
# make some edits
p4 submit -d "Made my edits."
p4 integ //depot/my_branch/... //depot/main/...
p4 resolve -am
p4 submit -d "Merged my edits into main."
Upvotes: 2