Where I work uses a Perforce environment but we are not allowed to check in until our features are completed and ready to be tested. I need to be able to do local commits because at times I have had upwards of 50 files checked out for a week without any versioning on my changes.
Git fits my purpose, but I am not sure how to set it up to best integrate with the rest of my environment.
My goals are:
It seems like creating a git repository at the root directory of my local workspace would work, but I have some issues...
Can anyone give me some tips about this? I've been looking at submodules in git as a way to potentially reduce the size of the git repo as there are a lot of portions of the perforce repo that I don't need versioning on.
Generally, git p4 clone is used to create a new Git directory from an existing p4 repository: $ git p4 clone //depot/path/project. This: Creates an empty Git repository in a subdirectory called project.
Different teams have different needs. Git version control might be a good choice for one team; Perforce might be the right version control for another. Native, open-source Git can work well. This is especially true for code-only projects with a small group of developers and fast release cycles.
You should go with git-p4. This answer might be helpful as well.
I am currently using exactly this workflow and it's pretty great
For corporate reasons I can't use the git-p4 commands, but I've got a git repo living inside my client workspace directory. Our setup has configuration-code-only checked in to source control, with the rest of the dev setup stored in a ZIP. Thus I never reconcile on the workspace root anyway, which has the added bonus of not needing to explicitly ignore .git
.
Addressing your points:
The initial commit can be expected to be...well, not the speediest. It's not cloning an existing repo, it's building one up from scratch.
Occasionally I'll save+commit what I'm working on,
git checkout master && p4 sync && git add --all . && git commit -mupdate && git checkout feature-branch
and then continue to hack. Merges tend to be much smoother in Git than in Perforce so usually you won't have to break focus because of conflicts. @p4mataway told me that they're working on merging better, though, so that'll be neat to see.
I turned on the 'allwrite' workspace option (don't keep unedited files read-only) and when I'm ready to check something in, I'll merge that branch down to master
and then Reconcile in P4V. I'd do that from the command-line too but, corporate reasons again. Long story.
Git has been tremendously useful to me when dealing with features that involve multiple changes to the same file, as tends to happen with long-pending changes - typically database schema changes that require our application's database to be reset and we don't want to do that on the test servers right now because QA are in the middle of scenarios. The longer a changelist stays around, the more likely some unrelated work is to touch one of the same files, and being able to branch locally keeps the changes from getting stuck together. That feature alone is enough to make this whole setup entirely worthwhile.
Disclaimer - I don't intend to keep this Git repo around forever. Once some of the Corporate Reasons are resolved with an upcoming server upgrade I'll be able to use some very shiny Perforce features that our current environment doesn't support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With