Last active
August 29, 2015 13:57
-
-
Save noel-yap/9532440 to your computer and use it in GitHub Desktop.
Iteratively convert Perforce repository to git -- preserves existing git commit hashes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 | |
| ) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://gist.github.com/noel-yap/2d084b543cfab0782edc for a version of this script that handles the initial import as well.