clusterBuddy
clusterBuddy

Reputation: 1554

How to change current repo to a new one while conserving all previous commits

My current state:

Expected state:

I am looking for a stenciled workflow solution, not a one time solution for this issue.

Not looking to create new branches on Master A as solution, please. I would like to keep Master A organic for others to pull and benefit with no clutter/branches.

Thanks,

Buddy

Upvotes: 0

Views: 38

Answers (1)

Udayraj Deshmukh
Udayraj Deshmukh

Reputation: 1914

To reproduce your scenario I created two repositories testgitA and testgitB. testgitA contains some commits as well as some new uncommitted changes, whereas testgitB is empty.

Now, for "B to include all the new and uncommitted written code from A + Include all commits of A", I'd follow these steps:

  1. Duplicate the folder testgitA into a new folder testgitB.

    cp -R testgitA/ testgitB/

    Note: This is to catch the uncommitted code.

  2. Go into testgitB and change the url of remote origin to new one.

    cd testgitB/ git config remote.origin.url "https://github.com/Udayraj123/testgitB"

  3. Now you commit your changes into testgitB, where testgitA remains unaffected.

    git add . && git commit -m "into testgitB"

  4. If you want to discard uncommitted changes in the boilerplate repo, use the following command.

    cd ../testgitA git add . git stash

Ref: More ways to discard uncommitted changes here

Upvotes: 1

Related Questions