So which is better, using git-p4 or just sliding a .git directory into the working directory and having perforce ignore it?

青春壹個敷衍的年華 提交于 2019-12-04 03:38:02

I used git-p4 at work. It's a bidirectional bridge so if you want to use git and then commit your local commits back into p4, it's a nice way to go. However, our office policy had a culture of a small number of massive commits rather than many small ones so I had to rebase all the changes into a single patch before submitting back into p4. I would have liked to maintain the fine grained local history but commit back in a single shot but never could manage.


Apropos change notification. git-p4 creates patches for every checkin since your last and submits them as separate changesets. This sort of mirrors the history of the main branch you're working on in your git repository.

I use git with TFS and have chosen to go with Option 2: slide the .git directory in and have TFS ignore it. I do this for the same reason that @Noufal does, we have a culture here of "one big commit" vs. the tens of tiny commits I do in Git. Since I'm only committing to TFS once or twice a day, it's not worth it for me to mess around with post-commit hooks or rebases or anything else.

I guess it really depends on the layout of your perforce repository - if you're working on a relatively small section of it, then I'd probably just go for dropping the .git directory straight in. It's the least path of resistance by far and I have used it successfully on smaller projects.

That said, I have struggled with this approach on larger repositories, probably as much to do with the workflow where I work as the management overhead of it all. I've yet to have a look at git-p4, but it's something I'm interested in investigating further.

The way I do it is to have a master branch and feature branches in git, and then use git diff --name-only master on a feature branch to figure out what files I've changed for a particular feature. I then check those files out into a Perforce changelist and submit it.

...well, more or less... :) In practice, we use Code Collaborator for code reviews, so I check the files out sometime between starting work on the feature and submitting the files for code review (it doesn't really matter much when). I then check before the code review that I've got all the files I should have using the above git command. (Actually, because I'm paranoid, I now do a git clean -xdf in my source directory and do a Perforce "Reconcile Offline Work" to double-check what I'm about to submit. I then do a full rebuild of the whole project. Breaking the build is embarrassing, after all.) Once all the reviewing's done, I just submit the changelist as normal.

It's a bit of a faff, really, but it's not so bad now that I've got used to it - and it's a lot better than just using Perforce with massive commits, and effectively working without any sort of version control for days at a time :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!