Skip to content

Instantly share code, notes, and snippets.

@ludovicc
Created December 12, 2011 20:13
Show Gist options
  • Save ludovicc/1468885 to your computer and use it in GitHub Desktop.
Save ludovicc/1468885 to your computer and use it in GitHub Desktop.
Git madness - Synchronisation from Git to P4
#
# Suppose that you are happily working with your sources in Git, and manager says 'Thou shalt use the company's Perforce repository'
#
# And you strike a deal: I keep working on Git, but all releases will also be published on Perforce
#
# === Initial setup, run this script once
# My project under Git is located at ~/MyProject
cd MyProject
# Create a published branch
git checkout -b published
mkdir -p ~/toP4 && cd ~/toP4
git-p4 clone //My/Perforce/Repo .
git remote add -t published local file:///home/lclaude/MyProject/
git fetch local published:published
git checkout published
git pull local
git branch --set-upstream published local/published
git checkout master
git checkout -b releases
touch README.txt
git add README.txt
git commit -m "Dummy commit"
# Run this script once for each release from the ~/MyProject directory
RELEASE=$1
cd ~/MyProject
git checkout published
git merge master
git checkout master
cd ~/toP4
git checkout published@{0}
git reset --soft releases
git commit -m "Release $RELEASE"
git branch temp
git checkout temp
git branch -M releases
git checkout master
git merge releases
git-p4 sync
git-p4 submit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment