Copy files from one remote to another using GIT

5

I have two remotes configured, the origin (repository in heroku) and github (repository in github). In my local repository I made several changes but I gave the push only in the origin, leaving the github without updates and commits. Now I would like to know how do I "copy" the origin (heroku) direct to github.

The steps I took were as follows:

git clone [email protected]:meurepo.git meurepo
cd meurepo
heroku create
git remote add github [email protected]:meuusuario/meurepo.git
git push github

At first it said that there was no data to update and that the repository was already updated but I knew it was not. After some commands like git remote update I tried to give git push github again and now the following error appears:

! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:rodrigokiller/speedup.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I tried to give git pull but the same error appears (from [rejected]).

    
asked by anonymous 17.03.2015 / 18:34

2 answers

1

Just set the new remote and give push to it.

git remote add <nome do novo remote> <url do novo remote>
git push <nome do novo remote> <url do novo remote>
    
17.03.2015 / 19:05
1

I was afraid of trying to fix the git pull github master because of what I understand, the "low" pull to the local repository, and since the github remote was outdated, I preferred to opt for the command that I was also afraid of:

git push --force github master .

When using this command, it worked and it looks like the new changes are now going to the two remotes (of course, pushing each one separately).

    
17.03.2015 / 19:29