Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
814 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...