Push command giving error


Please help!

I ignored it twice and then tried to view the site at my URL , but nothing is being showed , as nothing has been pushed to my repo.


It's telling you (read it) that there are commits on the remote repo that you need to add to yours before the remote will let you push to it.

So you'll need to decide which changes to keep, the remote ones, the local, or both.


Thank You. Now it works fine!


I am having the same problem and I tried executing "git pull" on the terminal. Then I tried "git push -u origin master" and it gives the same error. Can you show me the right push command?


There's a command in the instructions isn't there? If that's not successful, then you'll need to read the error message, they aren't there for the purpose of being ignored, they are there to tell you what went wrong!


I know, I read it and tried "git push" as it suggested me :slight_smile:
It didn't work as planned because I still see the error. Let me show you the output:

$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details

git pull

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=origin/ master

This is a learning website, please don't answer questions like this with an attitude.


Not giving you attitude, I'm simply pointing out where you're going wrong in your reasoning. Note: reasoning, not "this is the correct command" but instead "here's how you figure out what the correct command is"

Working with the command line is two-way communication, it's not about entering memorized commands, it's much more dynamic than that. You have to adapt to what is happening.

Didn't you say you wanted to push? Pull is the opposite, so that is not what you'll want to try.
So start by running the command suggested in the instructions and consider what it's telling you is wrong.


Yes you are, I'm gonna show you why. This is the output from "git push -u origin master "

Username for 'https://github.com': *******
Password for 'https://*******@github.com':
To https://github.com/*******/********.github.io
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/******/******.github.io'
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.

You see? the "hint" says that I should do git pull before pushing again. That's what I did. This is not stackoverflow, this is a learning site, users are not used to this kind of situation. :slight_smile:


I'm not saying you have to understand it. I'm saying that's where the information you need is. You can ask for help with understanding it, but you still have to go through that, at least you have to share that information so that the person helping has access to it.

It says your repository is behind the one that you are pushing to, so it refuses to accept your push.
You will need to merge the changes on the remote into your local repository before it will accept your push.

So yes, you need to pull.

If you haven't yet committed anything then you don't have a branch so you don't have anything to set upstream to
But you can pull from origin master, assuming that you have added your repository as a remote named origin.

Syntax for that is
git pull <remote> <branch>
Which my git helpfully tells me, whereas yours just says pull (I have a later git version)

But if you have a branch then you can set upstream with
git branch --set-upstream-to=origin/master master

If you've got changes, then they need to be merged when you push. If you add --rebase when pulling, then it will apply the changes of your commits on top of the ones it pulled instead of keeping them and adding a commit that merges them. If there are no conflicts that happens automatically, otherwise you'll need to merge manually.

EDIT actually, your git probably says that, you just didn't post the intact message!


Thanks for clarifying what was the problem. I entered the command git pull origin master and it merged the changes. Now it was possible to do a git pull without any errors. Sorry for the disagreement, you were really helpful!
Regards, Teo


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.