1

I have an existing repo that I want to add a new remote to, a sort of local repo for internal staging rather than pushing to origin.

I have created a new blank repo in GitHub, added the remote to my repo (with the name github) and tried :

git push github mybranch

I believe I have done this before and it worked, however now I'm getting an error telling me that updates were rejected because a pushed branch tip is behind its remote counterpart.

It wants me to git pull from the new repo - however it's empty.

What do I need to do in order for this to work? Is there a force option to just shove the code there?

shuttle87
  • 14,776
  • 9
  • 75
  • 105
  • 1
    Did you ask GitHub to create a `README.md`, `.gitignore` or `LICENSE` file for you when you created your repository? These options are all available from [the new repository form](https://github.com/new). – Chris Jun 05 '14 at 12:33
  • possible duplicate of [After creating a local git repo, how do I push it on Github?](http://stackoverflow.com/questions/11276364/after-creating-a-local-git-repo-how-do-i-push-it-on-github) – mort Jun 05 '14 at 14:52
  • @Chris, I think this was it. I used the -f (force?) flag as suggested below and it worked. Must be these files stopping it from being empty. Thanks again for the help. – user3711014 Jun 05 '14 at 15:17
  • possible duplicate of [Force git to overwrite remote files on push](http://stackoverflow.com/questions/10510462/force-git-to-overwrite-remote-files-on-push) – random Jun 08 '14 at 23:05

1 Answers1

0

Try this:

git push -f github mybranch
Sudhanshu Mishra
  • 1,885
  • 1
  • 20
  • 38
  • 2
    I wouldn't recommend forcing without explanation; that's a recipe for lost commits if the remotes are misconfigured, for example. This is a command that should be run with care. – Chris Jun 05 '14 at 12:45
  • Yes I agree with you. – Sudhanshu Mishra Jun 05 '14 at 12:53
  • This did the trick. I think it was related to the comment Chris made regarding README.md and .gitignore files. Many thanks to all that answered. – user3711014 Jun 05 '14 at 15:16
  • If this helped you, you should accept the answer. It helps others to find appropriate answers quickly and it also encourages people to answer more. – Sudhanshu Mishra Jun 05 '14 at 20:21