Skip to content

Instantly share code, notes, and snippets.

@thinkawitch
Last active May 17, 2019 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkawitch/4b0f2165f2fc938d65f2ce5c8a6edeb1 to your computer and use it in GitHub Desktop.
Save thinkawitch/4b0f2165f2fc938d65f2ce5c8a6edeb1 to your computer and use it in GitHub Desktop.
Git: extract commits / files from branch to create new clean repo with prev history
# https://stackoverflow.com/questions/28983842/remote-rejected-shallow-update-not-allowed-after-changing-git-remote-url
# https://stackoverflow.com/questions/29748197/how-to-clone-seed-kick-start-project-without-the-whole-history
1. git clone --single-branch --branch=commerce --depth=198 git@git.hostname.com:andrew/project.git ./
2. git remote remove origin
3. put the starting point hash to grafts (the commit you with to start new repo from, the last one of --depth)
echo "fc4c845f42adf3447f3b531398c69451bb11f6e7" >> .git/info/grafts
4. git filter-branch -- --all
5. rm -fr ./.git/refs/original
6. rm ./.git/shallow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment