Skip to content

Instantly share code, notes, and snippets.

View greuze's full-sized avatar

Iván López Santiago greuze

  • Telefónica I+D
  • Boecillo
View GitHub Profile
@greuze
greuze / move-folder-with-history.txt
Created April 10, 2019 09:11
Move folder to other repo with history
# Clone a fresh copy of origin repo and enter into it
git clone <giturl-repoA>
cd <repoA>
# Optional, to avoid pushing to the wrong remote repository
git remote rm origin
# From the repo source, remove all the files and history ourside the folder
git filter-branch --subdirectory-filter <folder-name> -- --all
# Optional, move all the files previously in the folder to a new one, as they are in the repo root now, and commit them (no push)
mkdir <directory-new-name>
mv * <directory-new-name>