Home > Enterprise >  git don't overwrite old commits but push new project folder
git don't overwrite old commits but push new project folder

Time:11-29

my react-native project was broken so I created a new folder and copyed all files to the new folder and reinstalled all packages. The project now works again and I would like to commit it to github.

But how do I commit these new changes without first pulling the old state and without overwriting the old commits?

I hope it's clear what I mean thank you for your time!

CodePudding user response:

Similar to what @joshmeranda suggested in the comments, this is what I would do:

  1. Delete old broken files
  2. Commit deleting them
  3. Copy new files to old project/folder
  4. Commit
  5. force-push your local changes to your remote

If you commit deleting old files and "creating" (copying) new files you should have a clean git history of what you did. After force pushing you should still be able to go back a few commits to your old changes.

Please do correct me if I'm wrong about this!

  • Related