Elad Benda
Elad Benda

Reputation: 36654

how to push an existing local branch to remote at gitHub?

I'm using sourceTree.

How can I push an existing local project (branch) to

a remote Gitbug repository I won?

I try and get this error:

git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags --set-upstream memPic master:master 
Pushing to https://github.com/elad2109/memPic.git
To https://github.com/elad2109/memPic.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/elad2109/memPic.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Completed with errors, see above

but anyway I'm not sure what are the required steps?

Upvotes: 0

Views: 621

Answers (2)

Adam Arold
Adam Arold

Reputation: 30528

This is not a github problem but a git problem. You can't make a non-fast-forward push without merging/rebasing. Please check the corresponding parts of the documentation.

This site is a great help for understanding the problem!

So you basically either have to git pull or git pull --rebase.

Upvotes: 2

cforbish
cforbish

Reputation: 8819

This is failing because the tip of your branch is behind its remote. This might happen if there was a fetch without a rebase.

There are two ways to fix. To keep the remote changes add git rebase, before your command. To discard the other changes (not recommended) add a -f to your push command.

Upvotes: 0

Related Questions