* How to replace master branch of a repo with that of another totally unrelated repo?
@ 2010-08-06 7:38 PCMan
2010-08-06 8:07 ` Ramkumar Ramachandra
0 siblings, 1 reply; 3+ messages in thread
From: PCMan @ 2010-08-06 7:38 UTC (permalink / raw)
To: git
Hello,
I want to rewrite a program totally from scratch rather than branching
from current one.
So I created a new repo for it and do the development there.
Now it's finished and I want to replace the old program with it.
Is it possible to replace the master branch of the old repo with the
code in this new repo?
I want to move the old code to a separate branch for backup, and
replace the master branch with the master branch of the new repo.
Since git rm -r * than git add all new files will lost history of new
repo, it's not an option.
The old repo is a public online repo used by multiple users. So just
renaming the repo won't work since the users who pull code from the
old repo will get troubles.
What's the best strategy for smooth migration in this case?
I'm not able to find the answer on Google.
Thank you all.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to replace master branch of a repo with that of another totally unrelated repo?
2010-08-06 7:38 How to replace master branch of a repo with that of another totally unrelated repo? PCMan
@ 2010-08-06 8:07 ` Ramkumar Ramachandra
2010-08-06 8:21 ` PCMan
0 siblings, 1 reply; 3+ messages in thread
From: Ramkumar Ramachandra @ 2010-08-06 8:07 UTC (permalink / raw)
To: PCMan; +Cc: git
Hi,
PCMan writes:
> I want to rewrite a program totally from scratch rather than branching
> from current one.
> So I created a new repo for it and do the development there.
> Now it's finished and I want to replace the old program with it.
> Is it possible to replace the master branch of the old repo with the
> code in this new repo?
> I want to move the old code to a separate branch for backup, and
> replace the master branch with the master branch of the new repo.
> Since git rm -r * than git add all new files will lost history of new
> repo, it's not an option.
> The old repo is a public online repo used by multiple users. So just
> renaming the repo won't work since the users who pull code from the
> old repo will get troubles.
> What's the best strategy for smooth migration in this case?
> I'm not able to find the answer on Google.
In your old repository:
$ git checkout master # Switch to branch master
$ git checkout -b backup # Create a branch backup of master
$ git remote add new <new_repository_url> # "new" is the name of the remote
$ git fetch new # Fetch all the objects from the remote "new"
$ git checkout master # Get ready to rewrite master
$ git reset --hard new/master # Use `reset --hard` with extreme caution
$ git checkout backup # Your backup is safe here
$ # Done!
-- Ram
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to replace master branch of a repo with that of another totally unrelated repo?
2010-08-06 8:07 ` Ramkumar Ramachandra
@ 2010-08-06 8:21 ` PCMan
0 siblings, 0 replies; 3+ messages in thread
From: PCMan @ 2010-08-06 8:21 UTC (permalink / raw)
To: Ramkumar Ramachandra; +Cc: git
Thank you for the detailed answer! It's really useful.
Now I fetch the new source code to a new branch.
Later I plan to replace master with merge --ours when it's ready.
Thanks
On Fri, Aug 6, 2010 at 4:07 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
> Hi,
>
> PCMan writes:
>> I want to rewrite a program totally from scratch rather than branching
>> from current one.
>> So I created a new repo for it and do the development there.
>> Now it's finished and I want to replace the old program with it.
>> Is it possible to replace the master branch of the old repo with the
>> code in this new repo?
>> I want to move the old code to a separate branch for backup, and
>> replace the master branch with the master branch of the new repo.
>> Since git rm -r * than git add all new files will lost history of new
>> repo, it's not an option.
>> The old repo is a public online repo used by multiple users. So just
>> renaming the repo won't work since the users who pull code from the
>> old repo will get troubles.
>> What's the best strategy for smooth migration in this case?
>> I'm not able to find the answer on Google.
>
> In your old repository:
> $ git checkout master # Switch to branch master
> $ git checkout -b backup # Create a branch backup of master
> $ git remote add new <new_repository_url> # "new" is the name of the remote
> $ git fetch new # Fetch all the objects from the remote "new"
> $ git checkout master # Get ready to rewrite master
> $ git reset --hard new/master # Use `reset --hard` with extreme caution
> $ git checkout backup # Your backup is safe here
> $ # Done!
>
> -- Ram
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-06 8:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-06 7:38 How to replace master branch of a repo with that of another totally unrelated repo? PCMan
2010-08-06 8:07 ` Ramkumar Ramachandra
2010-08-06 8:21 ` PCMan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).