Skip to content

Instantly share code, notes, and snippets.

@vctrtvfrrr
Created August 30, 2023 20:47
Show Gist options
  • Save vctrtvfrrr/9080cf0c9732d095fcbbaba0242ab520 to your computer and use it in GitHub Desktop.
Save vctrtvfrrr/9080cf0c9732d095fcbbaba0242ab520 to your computer and use it in GitHub Desktop.
Copiar uma branch completa para outro repositório
#!/bin/bash
DIR="$PWD/TmpFolder"
rm -fr "$DIR"
mkdir "$DIR"
function git_from() {
GIT_DIR="$PWD/.git-from" git -C "$DIR" $@
}
function git_to() {
GIT_DIR="$PWD/.git-to" git -C "$DIR" "$@"
}
git_from rev-list --reverse master | while read commit_hash; do
git_from reset --hard
git_from clean -df
git_from checkout $commit_hash
commit_subject=$(git_from log --format=%s -n 1 $commit_hash)
commit_date=$(git_from log --format=%ad -n 1 $commit_hash)
git_to add .
GIT_COMMITTER_DATE="$commit_date"
git_to commit -m "$commit_subject" --date="$commit_date" --no-verify
done
rsync -a "$PWD/.git-to/" "$PWD/$DIR/.git/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment