<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Perforce on bramp.net</title>
    <link>https://blog.bramp.net/</link>
    <description>Recent content in Perforce on bramp.net</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-GB</language>
    <lastBuildDate>Tue, 04 Sep 2012 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://blog.bramp.net/tags/perforce/" rel="self" type="application/rss+xml" />
    
    <item>
      <title>Setting up git-p4</title>
      <link>https://blog.bramp.net/post/2012/09/04/setting-up-git-p4/</link>
      <pubDate>Tue, 04 Sep 2012 00:00:00 +0000</pubDate>
      
      <guid>https://blog.bramp.net/post/2012/09/04/setting-up-git-p4/</guid>
      <description><p>I couldn’t find a good article on setting up git-p4, and for some reason most of the articles out there point to dead URLs. So I figured I’d quickly write this up.</p>
<p>Git-p4 is a tool for using git on top of a perforce server. This is great if your team wants to work with a DVCS, but your company requires a centralised VCS.</p>
<p>There were multiple github projects <a href="https://github.com/baldrick/git-p4/">1</a>, <a href="https://github.com/gkielSfdc/git-p4">2</a>, <a href="https://github.com/jendave/git-p4">3</a>, that had forks of the git-p4 script, however, I found the latest mixed in with the official git source code. So download it from <a href="https://raw.github.com/git/git/master/git-p4.py">here</a>. Tip: Don’t forget to “chmod +x git-p4.py” once it’s downloaded.</p>
<p>Next, I wanted to be able to type “git p4″, so I used an <a href="https://git.wiki.kernel.org/index.php/Aliases">alias</a> to do this. Edit/create the file ~/.gitconfig and add:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-ini" data-lang="ini"><span class="line"><span class="cl"><span class="k">[alias]</span>
</span></span><span class="line"><span class="cl"><span class="na">p4</span> <span class="o">=</span> <span class="s">!~/bin/git-p4.py</span>
</span></span></code></pre></div><p>Once that’s done you should be able to:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># Fetch only the head</span>
</span></span><span class="line"><span class="cl">git p4 clone //depot/path/to/project/ project
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># or Fetch all revisions (takes a little longer)</span>
</span></span><span class="line"><span class="cl">git p4 clone //depot/path/to/project/@all project
</span></span></code></pre></div><p>If that returns an error, such as “p4 returned an error: Perforce password (P4PASSWD) invalid or unset.”, then you most likely don’t have your p4 command line set up. To set mine up, I added the following to my .bashrc</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">P4CLIENT</span><span class="o">=</span>myclient
</span></span><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">P4HOST</span><span class="o">=</span>perforce:1666
</span></span><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">P4USER</span><span class="o">=</span>myuser
</span></span><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">P4EDITOR</span><span class="o">=</span>nano
</span></span></code></pre></div><p>and then logged in</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">p4 login
</span></span></code></pre></div><p>More information on that set up can be found in the <a href="http://www.perforce.com/perforce/doc.current/manuals/p4guide/02_config.html"> official documentation</a>.</p>
<p>Once cloned, you can change to the project directory and use many of the normal git commands, such as “git log”. You may notice that your newly checked out git repo only has one commit. If you want to see a full history use @all on the end of your depot path.</p></description>
    </item>
    
  </channel>
</rss>
