1

I tried all duplicated questions, but none of them worked. Please can you write correct syntax respectively for me?

I tried respectively:

git add .

git commit -m "comment"

git remote add origin https://github.com/dgknca/DogukanCavus_H5180005-MuhammetFurkanAydogdu_H5180045

git push -u origin master

push -f works, but I don't want use it. Because it's deleting all previous commits.

This is my error:

sezginc@dgknca MINGW64 ~/desktop/DogukanCavus_H5180005-MuhammetFurkanAydogdu_H5180045-master (master)
$ git push -u origin master
To https://github.com/dgknca/DogukanCavus_H5180005-MuhammetFurkanAydogdu_H5180045
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/dgknca/DogukanCavus_H5180005-MuhammetFurkanAydogdu_H5180045'
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ğukan
  • 23,073
  • 13
  • 57
  • 69

1 Answers1

2

From the message it sounds like there are commits in the remote that you are missing in your local. Try comparing:

git fetch origin
git diff origin/master

That should show you what you are missing. If your current branch can be brought up to sync, you should be able to just do:

git pull origin master

Then, unless there are merge conflicts, your push should work. You may want to create another branch just to test it out to leave your local branch in its current state and avoid git fiddling if the pull doesn't go smoothly.

Fincher
  • 100
  • 10
  • it's don't solved my problem. I still taking same error. – doğukan Jan 17 '19 at 22:00
  • Ok, so there are some changes. I'd then look at the commits to see what might be missing. Here's what I would try. Create a new branch, something like logtesting. Look at the results of git log and then do a git reset --hard to the first commit. Then git pull origin master Then you will have a new branch that should match what's in the remote (unless the first commit is different too). Then you can do git log on that branch, switch to your other branch, do git log there, and compare. You should see at least one commit in this new branch not in the original. – Fincher Jan 19 '19 at 03:21