0

I use Git for my source control. I'm not fully comprehending what's going on, thought I had it running just fine. Then I went to commit the latest branch, which apparently worked,but when I tried a push, I got this:

enter image description here

I'm afraid if I merge the changes by doing a git pull, I'll really farkel the good branch. When I look at the file status on SourceTree, I have this:

enter image description here

How do I fix this mess so I can continue working on a new branch? I'm afraid to try anything like

git pull --rebase origin master

without someone who knows a lot more than I telling me it's ok and will fix my problem...

UPDATE: Did the push again using the correct branchs and this is what I got:

git -c diff.mnemonicprefix=false -c core.quotepath=false push -v SalonBook 1.9.3:1.9.3 
Pushing to https://SpokaneDude@bitbucket.org/SpokaneDude/salonbook-git.git
git: 'credential-osxkeychain' is not a git command. See 'git --help'.
git: 'credential-osxkeychain' is not a git command. See 'git --help'.
To https://SpokaneDude@bitbucket.org/SpokaneDude/salonbook-git.git
 ! [rejected]        1.9.3 -> 1.9.3 (non-fast-forward)
error: failed to push some refs to 'https://SpokaneDude@bitbucket.org/SpokaneDude   /salonbook-git.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and merge the remote changes
hint: (e.g. 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Completed with errors, see above
SpokaneDude
  • 4,856
  • 13
  • 64
  • 120
  • 1
    You could create a new branch from *master* and try the merge in that branch. If it succeeds, you can merge *master* as well. – Gumbo Feb 12 '14 at 18:25
  • Isn't that just a 'band-aid' approach? Isn't there a better way of fixing this? what about the *git pull -rebase origin master* command? I'd really like to get rid of the *4 ahead, 1 behind* mess... – SpokaneDude Feb 12 '14 at 18:28
  • 1
    Why is it trying to push local 1.9.4 to remote 1.9.3? Shouldn't it push local 1.9.4 to remote 1.9.4? – rob mayoff Feb 12 '14 at 20:01
  • Oops... you're right! So I tried the corrected push and I posted the results on the question update above... – SpokaneDude Feb 12 '14 at 20:27

2 Answers2

0

You should do a git pull before you push.

This will fetch any changes from the remote branch and merge them locally.

Then you will be able to push.

jordelver
  • 8,292
  • 2
  • 32
  • 40
  • Thanks to all for suggesting how to fix it... I tried all of the suggestions, and wound up deleting everything (local and remote) and starting from the beginning... it's clean and working now the way it should. – SpokaneDude Feb 13 '14 at 00:07
  • thanks for that, i didn't know git pull merges locally, i thought it was just a straight replacement. – Kris Welsh Apr 22 '14 at 21:53
0

git pull --rebase will fix your problem. Being behind by X commits is not a big deal and just means that someone else pushed commits to the remote before you did.

This is a common occurence when multiple are working on the same remote repo.

Schleis
  • 41,516
  • 7
  • 68
  • 87