Why "git push origin master" doesn't work? - github

I follow steps in http://jekyllbootstrap.com/usage/jekyll-quick-start.html to install Jekyll-Bootstrap.
I can run
http://localhost:4000
in local and I have set ssh, but git push origin master doesn't work.
--- This is the error interface ---
$ git push origin master To git#github.com:XXX/XXX.github.com.git !
[rejected] master -> master (non-fast-forward) error: failed to
push some refs to 'git#github.com:XXX/XXX.github.com.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.
Does someone know why git push origin master doesn't work?

The error message already tells you everything you need to solve the issue. Before a git push origin master you should do a git pull origin master to ensure you have the latest updates from the server.
If you are getting this message you did work on an older version of the repository instead of the latest one.

As the error says, you need to do a pull before you can do the push. The problem is that the code you are trying to push doesn't have the latest changes from the master, so it cannot be merged correctly. Try the pull first to get all the latest changes.

Related

Having trouble pushing up my projects to GitHub

I am having difficulty pushing up my code to GitHub.
I have a GitHub account and have created the repo:
cd into project folder
git init
Result:
Reinitialized existing Git repository in /Users/blakeflowers/Documents/fake-news-app/.git/
git remote add origin https://github.com/devnoob-flowers/shit-they-say.git
Result:
fatal: remote origin already exists.
git add .
Results: seems to do nothing
git commit -m "Practice Push"
Results:
On branch master
nothing to commit, working tree clean
git push -u origin master
To https://github.com/devnoob-flowers/shit-they-say.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/devnoob-flowers/shit-they-say.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
So clearly I have no idea what the heck is going on.
Once again im trying to push my code up to GitHub and eventually deploy the site using Github pages. just something im doing for practice.
I solved it by finding some terminal code but I don't understand it. Can anyone explain?
This solved my problem:
git fetch origin master:tmp
git rebase tmp
git push origin HEAD:master
git branch -D tmp

(GitHub push) Updates were rejected because the tip of your current branch is behind

I am trying to push to a repository that unfortunately got severed from my client terminal in my text editor.
The error that comes up is:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/jboyle1/milestoneproject-004.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.
So I try and:
git pull repo_name
but it says:
remote: Repository not found.
Its probably a simple fix but I'm struggling.
It should be simply git pull (or git pull origin master)
Check the output of git remote -v, and see if "origin" does reference the remote repository URL.

Problems syncing to GitHub

I am trying to push data to remote repo. Keep going round in circles.
I think that i have made a small mistake which is holding me back.
p#LAPTOP-O5L8LHSL MINGW64 ~/DataScience (master)
$ git push --set-upstream origin master
To https://github.com/adkin1988/datasciencecoursera.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/adkin1988/datasciencecoursera.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.
hp#LAPTOP-O5L8LHSL MINGW64 ~/DataScience (master)
$ 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 <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> master
you need to define which remote branch is related with your current local branch. see the last line of the code you have pasted

Can't push in github before pulling. Is it because I changed my code through github website before?

I can't push to github. I think I have made changes in my code through github website before and now it gives me a hint when I do git push origin master:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/hrvoojex/telecom-toplist.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.
Do I just have to do:
git pull origin master
and after that I will be able to do:
git push origin master
I made a lot of changes in my code localy so I don't want to lose al of my work till now from the last commit.
Basically you have got two solutions:
If your local copy is the good one, you may want to overwrite the remote work. You can do that with a simple force push.
git push -f origin master
If you want both changes, you can merge remote work to local one, and then push the result. In that case, the suggested commands are the way to go.

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?
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.
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.