Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save noel-yap/9532440 to your computer and use it in GitHub Desktop.

Select an option

Save noel-yap/9532440 to your computer and use it in GitHub Desktop.
Iteratively convert Perforce repository to git -- preserves existing git commit hashes.
#!/bin/bash -evx
PERFORCE_DEPOT_PATH=$1
GIT_REPOSITORY_URL=$2
git_project_name=$(echo ${GIT_REPOSITORY_URL} | sed -e 's|^.*/||' -e 's|\.git||')
rm -rf ${git_project_name}
git clone ${GIT_REPOSITORY_URL}
(
cd ${git_project_name}
git update-ref refs/remotes/p4/master $(git log --format='%H' | head -n 1)
git symbolic-ref refs/remotes/p4/HEAD refs/remotes/p4/master
git p4 sync ${PERFORCE_DEPOT_PATH} || true
git p4 rebase
git push
)
@noel-yap

Copy link
Copy Markdown
Author

See https://gist.github.com/noel-yap/2d084b543cfab0782edc for a version of this script that handles the initial import as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment