October 5, 2012

Understand Your New Git Users

Media & Entertainment
Healthcare
Git at Scale

Are you a Perforce administrator considering Git Fusion as a way to support your Git users? Do they use strange words like “commit” and “rebase”? What are they talking about? Git Fusion serves as a translator between Git and Perforce, but sometimes you need a translator between Git users and Perforce users.

Git Commit = Perforce Changelist

A Git “commit” is the same idea as a Perforce “changelist”. Both objects contain a set of changes to files, grouped together in a single transaction, along with some description and attribution.

Git Branch ≠ Perforce Branch

A Git branch differs greatly from a Perforce branch. A Perforce branch is a branch of file hierarchy. A Git branch is a branch of workspace history.

Many long-time Perforce users have a hard time wrapping their head around this, so let’s go to the whiteboard:

Think about how easy it is in Perforce to ‘p4 sync @101’ and now your workspace looks just like it did at change 101. Then ‘p4 sync @103’ and now your world looks like it did at change 103.

git fusion vocab 1

Git history is similar, just replace Perforce changelist numbers with Git commit sha1 numbers (here simplified to single letters). Run ‘git checkout A’ to make your workspace look like it did at commit A. Run ‘git checkout C’ and now your world looks like it did at commit C.

git fusion vocab 2

Next comes a bit of a leap. Git commit history does not have to be linear. Histories can diverge. So you can run ‘git checkout Y’ and end up in some alternate history. Your world now looks like it did at commit Y:

git fusion vocab 3

That alternate history? That is a Git branch. No branch spec. No change in depot path from //depot/MAIN/dir to //depot/SOMEBRANCH/dir. Just a change from one Git commit to another.

Git Rebase = Replay History

Git users tend to work in branches. Lots of little branches. To get work from a branch into the main codeline, Git users can either merge or rebase. Git merge combines two branches of workspace history. Here a merge commit M joins two histories ABC and XY:

git fusion vocab 4

Git rebase has no close counterpart in Perforce. Instead of creating a merge commit, Git rebase replays one branch’s history on to another branch. This replay is smart enough to retain both branches’ work.

git fusion vocab 5

Learn More About Git Fusion

Want to learn more about your Git users and how to support them? Head to our Git Fusion page to learn how you can help your Git users and Perforce users each get more out of their preferred tools.