Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
781 views
in Technique[技术] by (71.8m points)

ruby on rails - Deploying a Re-Written Github/Heroku App

I have an app that is live on Heroku/Github, but recently completely rebuilt it from scratch - I want to keep the old repository name, what is the best way to replace the live code with the new code?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Slight variation from Michael's answer:

git branch -M master old_master
git rm -rf .
git checkout --orphan master
git remote add version2 "/path/to/new_version/.git"
git pull version2 master

(as usual, back up everything first)

If you are using git1.7.2+, you can use git checkout --orphan:

Similar to -b, --orphan creates a new branch, but it starts without any commit.
After running "git checkout --orphan newbranch", you are on a new branch "newbranch", and the first commit you create from this state will start a new history without any ancestry.

When creating a branch whose trees have no resemblance to the ones from the original branch, it may be easier to start work on the new branch by untracking and removing all working tree files that came from the original branch, by running a 'git rm -rf .' immediately after running "checkout --orphan".

You avoid having two different history on the same branch, with an abrupt change at one specific commit.
Instead you keep several root branches with different history in it.
But that means rewriting the history of commits of master, which isn't that bad considering you only need the previous history for reference and archive only.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...