Git: Is there a way to change the local repository for a remote repo?

Viewed 43

I'm currently creating a web server using AWS, and as a test, I made a simple server in a folder. I initialized a git repo and then pushed to the remote repo, where my pipeline detected a change and redeployed the server with the new files. In a different folder, I have stored the server I actually want to use. When I initialize a git repo in the directory and set the remote's origin to the same as the other folder's remote's origin, no branches are detected when I run git branch -a. I guess I understand why this shouldn't be allowed, because the files weren't being tracked in the first place, but I'm wondering if there's a way I can remove the old commit history (which I found how to do in another post) and use this folder as the source of truth.

I can quite easily work around this by just copying all the files over, deleting the old commit history, and then pushing again, but I'm just curious if this other method is feasible.

Thank you.

0 Answers
Related