简体   繁体   中英

How to push a master branch to another address that already has a git repository?

I have two bare repositories:

  • A old one, with the live website that should be updated - located under private/repos/live_site.git ; and the live site files are under www/www

  • A new one, with the new website that should go live - located under private/repos/new_site.git ; and the new website files are under www/new/

I need to pass all data from www/new/ to www/www

Is there a way to do it using git, in a less "harder way"*.

*By harder way I mean:

1) remove all that is inside www/www ;

2) ssh to the remote server;

3) clone new_site.git into www/www ;

If more details are necessary, please, let me know.

It sounds a bit overcomplicated to me. Why don't you try to just point your server to a new repo having all new web site? If this is not an option for whatever reason, then you can merge two histories:

have a local cloned repo of live. Connect to the remote new, fetch all the info. then you have a choice of either merging the histories or just switching one of the brances of live (master) to the new/master

git checkout master # make sure there is no uncommitted stuff to avoid loosing some work

git reset --hard new/master

The whole working directory will change to reflect the state of the new/master you can move all files now from www/new folder to www/www folder. Commit the move and force push it to the live remote.

I think you can easily move around the folders for everything to work, unless there are some configuration files inside which need to be accordingly modified.

mv www/www www/old
mv www/new www/www

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM