Can I overwrite a Git repo with a completely new project?

Viewed 108

I got a new computer yesterday. I am coding in Android Studio for a course that I'm taking, and I figured it would be as easy as re-downloading Android Studio and cloning my repo onto the new computer. It isn't.

Something is messed up about my Gradle version, and I don't have the time to figure it out before the next due date.

The solution I've potentially come up with is, because my program is relatively small at the moment (only a couple files beyond the boiler-plate files that come with any Android activity), to just copy and paste the Java code from each of my files into a newly generated empty activity with all the right Gradle versions, and then just push that to the repository.

My question is: is that possible to do? If so, is it as easy as just pushing the new project (without having ever cloned the repository), or is it more complicated? If possible, elaboration on an answer would be greatly appreciated.

Thank you!

2 Answers

It's very straightforward to do it:

  1. Clone the desired original project

  2. Add your desired code on top of the clone

  3. Add & commit your changed

  4. Now you can push your changes in several ways:

    • You can have a new commit git push origin <branch name>
    • You can overwrite the current commit on your remote git push -f the -f will force to "overwrite" the existing code

enter image description here


enter image description here

Yes, you can. You just have to link your new local project to the git repository, once you push the new changes they will erase the old ones.

Related