Git for Perforce users

前端 未结 7 2033
故里飘歌
故里飘歌 2020-12-22 15:12

I\'ve been using Perforce for a number of years. I\'d like to switch to using git for my personal code, but all of the git tutorials that I\'ve seen either assume that you\'

相关标签:
7条回答
  • 2020-12-22 16:11

    Having used both Perforce and git fairly extensively, there's only one way I can see to get anywhere near Perforce changelists with git.

    The first thing to understand is that to correctly implement this functionality in git in such a way that it's a not a complete kluge, e.g. trying to shoehorn it into branches, would require the following change: git would require multiple staging areas for a single branch.

    Perforce changelists permit a workflow that simply has no equivalent in git. Consider the following workflow:

    Check out a branch
    Modify file A and add it to changelist 1
    Modify file B and add it to changelist 2
    

    If you try to do this using branches in git you'll wind up with two branches, one of which has the changes to file A, the other has the changes to file B, but no place where you can see the changes to both files A and B at the same time.

    The closest approximation I can see is to use git add . -p and then use the 'a' and 'd' sub-commands to select or reject entire files. However that's not quite the same, and the difference here stems from a fundamental disparity in the general modus operandi of the two systems.

    Git (and subversion, not that it matters for this discussion) allow a file to be changed without telling anyone about this ahead of time. You just change a file, and then let git sort it all out when you commit the changes. Perforce requires you to actively check out a file before changes are allowed, and it is for this reason that changelists have to exist. In essence, Perforce requires you to add a file to the index before changing it. Hence the necessity for multiple changelists in Perforce, and also the reason why git has no equivalent. It simply doesn't need them.

    0 讨论(0)
提交回复
热议问题