0

My current state:

  • Created and commited a JS development environment - call it Master A.
  • Continued to write new code on Master A, yet didn't commit any of the new code yet.

Expected state:

  • I would like my initial commit to Master B to include all the new and uncommitted written code from Master A + Include all commits of Master A.
  • I would like to have Master A available and re-usable to use it as a boilerplate for future JS environment projects.

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

Community
  • 1
  • 1
clusterBuddy
  • 1,523
  • 12
  • 39

1 Answers1

1

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

Udayraj Deshmukh
  • 1,814
  • 1
  • 14
  • 22