0

As you can see from the picture the last 4 commits from me haven't been pushed because another person made a commit before me and I did not pull. Now it says that I am 4 ahead and 1 behind. When I try to push it says:

    To git@XX.XX.XX.XX:compudoc.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@XX.XX.XX.XX:compudoc.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. If you did not intend to push that branch, you may want to
hint: specify branches to push or set the 'push.default' configuration variable
hint: to 'simple', 'current' or 'upstream' to push only the current branch.

How can I fix it ?

mTorres
  • 3,590
  • 2
  • 25
  • 36
Denki
  • 363
  • 2
  • 14

2 Answers2

0

So you can't push before pull. type git pull, when git push or git push origin master Good luck.

  • When I try that it says: `You are not currently on a branch. Please specify which branch you want to merge with. See git-pull(1) for details. git pull ` – Denki Feb 17 '15 at 13:17
  • You are on deatched head. If you want to save your changes, type `git checkout -b tmpbranch`, when commit your changes `git commit -am "msg"`, when `checkout master` and `merge tmpbranch` – user3085512 Feb 18 '15 at 10:26
  • If you don't want keep your changes, you can `git stash`, when `checkout master` or you can `git add .`, `git reset --hard`, and when `git checkout master` – user3085512 Feb 18 '15 at 10:36
0

You need to pull master, rebase it and then you can push.

git fetch origin

git rebase origin/master

git push origin master

Run those 3 in order and you should be good to go. Rebasing will show up any merge conflicts if you have them.

Max Woolf
  • 3,988
  • 1
  • 26
  • 39