1

Is there any way or any tool or commands to re write the history of master or some A branch from some commit number to newly created master branch of NEW REPOSITORY with master branch with 0 commits or no history.

In such a way that :

  1. All the previous commits before commit number "45678" should be re written as single commit in the new repository master branch
  2. Rewriting the history should begin from commit "45678"

Thanks

Shan Khan
  • 7,576
  • 11
  • 52
  • 95

1 Answers1

0

(I don't have a suitable sacrificial repository to test this: you've been warned).

I would think merge --squash could do this.

  • Add new repository as remote
  • Create dest branch, push branch with upstream tracking to the new repository
  • Checkout the new branch
  • Merge --squash from your source branch
  • Commit
  • Push to the new repository

(See this answer as well.)

Old Content (before question edit)

Just create the new repository as a new remote on your clone of the original repository; and then push to the new repository.

git remote add newrep url-to-new-repository
git push -u newrep master

Repeat the last command for each branch you want to push.

Richard
  • 100,436
  • 21
  • 189
  • 251