Git for Perforce users

前端 未结 7 2037
故里飘歌
故里飘歌 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条回答
  •  萌比男神i
    2020-12-22 16:07

    There is a more lightweight alternative in git that could form part of your workflow; using the git staging area.

    I often just make changes then submit as several commits (e.g. add debug statements, refactor, actually fix a bug). Rather than setting up your perforce changelists, then make changes, then submit, you can just make your changes then choose how to submit them (optionally using the git staging area).

    You can commit particular files from the command line with:

    git commit a.txt
    git commit z.txt
    

    Or explicitly staging the files first:

    git add a.txt
    git commit
    git add z.txt
    git commit
    

    git gui will let you select lines or hunks from within files to build up a commit in the staging area. This is very useful if you have changes in one file that you want to be in different commits. Having moved from git to perforce and this is one thing that I really miss.

    There is a small caveat to bear in mind with this workflow. If you make changes A and B to a file, test the file, then commit A then you haven't tested that commit (independently of B).

提交回复
热议问题