Skip to content

Instantly share code, notes, and snippets.

@thangtv611
Last active November 26, 2021 02:20
Show Gist options
  • Save thangtv611/b16b9379a00503c59c7f22125029d4eb to your computer and use it in GitHub Desktop.
Save thangtv611/b16b9379a00503c59c7f22125029d4eb to your computer and use it in GitHub Desktop.
Some tricks about git

Move to new remote

git clone --mirror <old-repo-url>
cd <repo-name>
git remote add new-origin <new-repo-url>
git push new-origin --mirror

Convert subfolder to a git repo:

git checkout your_branch_name
git filter-branch --prune-empty --subdirectory-filter relative/path/to/subdirectory your_current_branch_name
git remote set-url origin https://github.com/ao/your_new_sub_repo.git
git push -u origin your_current_branch_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment