SoSimple
SoSimple

Reputation: 701

Branch Then 'Reset' Rails Git Repository

I have a bit of a tricky problem. I restarted a current rails project from scratch in a new folder because I was redoing the app as a personal exercise. We've run into some issues on the 'official' version and now need to restart the project.

The problem is that we've been using git to keep track on the official project but I haven't been using it for my personal version.

I've branched the official git master repository using

git checkout -b restart_app

Now I'd like to clear out all the code in that branch and replace it with my personal version. I've tried to google the best approach to doing so but found some differing answers and I'm pretty new to working with git so I thought I'd put up a question here. What would be the best practice/solution for approaching this problem?

Upvotes: 1

Views: 58

Answers (1)

VonC
VonC

Reputation: 1324063

"I want replace all the files in restart_app with files from a different project folder"

Delete and replace the files by the ones you want.
The best practice is to do a git rm * first, then add your files, git add and commit.

A nice trick, you can use the --work-tree option of git:

git checkout restart_app
git rm -rf .
git add -A .
git commit -m "empty restart_app"

git --work-tree=/path/to/untracked/code add .
git commit -m "add new code"

Upvotes: 1

Related Questions