Can't Push or Pull in Git
Asked Answered
O

3

9

I'm fairly new to using Git, but I do understand the bare basics. However, I have yet to encounter a situation where I have Push/Pull conflicts...until now.

Also, I should point out that the GUI tool I'm using to interact with the Git repository is Atlassian SourceTree (We're using Atlassian Stash to manage our repo's).

Here is the scenario:

I have 2 commits to Push and apparently there are 4 changes that I need to Pull.

When I try to Pull I get this:

git -c diff.mnemonicprefix=false -c core.quotepath=false fetch origin

git -c diff.mnemonicprefix=false -c core.quotepath=false pull --no-commit origin master
You have not concluded your merge (MERGE_HEAD exists).

Please, commit your changes before you can merge.

Completed with errors, see above.

It says that I need to complete my merge but it's not allowing me to do anything. I don't get a merge list nor is it auto-merging. I can't seem to get past the merge so I can proceed to resolve the Push/Pull conflict.

When I try to Push I get this:

git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags origin master:master
Pushing to http://[email protected]:XXXX/XXXX/XXXX/XXXXX.git
To http://[email protected]:XXXX/XXXX/XXXX/XXXXX.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'http://[email protected]:XXXX/XXXX/XXXX/XXXXX.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.

Now how the heck do I resolve this?! Am I going to have to Rebase or something like that?

I was reading about a Fast Forward Push but I have no clue how to do that within this tool. If I have to, I can certainly execute the Git commands from the terminal. I just didn't want to jump into that without consulting someone with with a better understanding of Git and these types of issues.

Onitaonlooker answered 18/11, 2015 at 0:39 Comment(1)
I just realized I probably sounded really stupid asking my question and posting the Pull output that said "You have not concluded your merge (MERGE_HEAD exists). Please, commit your changes before you can merge." without mentioning the fact that it would not allow me to merge anything. That may have contributed to the down vote on my post. I've edited my post to mention that issue.Onitaonlooker
L
9

It looks like you're in the middle of a merge(perhaps a previous attempt?)

git merge --abort will cancel that merge, and put you in a state where you can retry the pull and then resolve conflicts.

Looby answered 18/11, 2015 at 0:43 Comment(2)
Thank you for your response. I was able to get things working by following your suggestion. I tried it a couple times but I was still seeing the same issue. So I tried closing SourceTree before running git merge --abort again and then I proceeded to Pull once more. I then opened SourceTree and my merge list finally appeared. I was able to proceed with the merge and resolved all other issues.Onitaonlooker
Thank you for your assistance! I really appreciate it.Onitaonlooker
S
1

Complete your merge. git status will tell you what is hanging out. For each one, you need to edit to fix the conflict and do git add. Then git commit. Then pull, then push.

Steffie answered 18/11, 2015 at 0:43 Comment(1)
Thank you for your response as well. If something weird wasn't going on when I attempted to merge, your answer may have been an acceptable solution to handle the issue. However, I selected @Darren Clark's answer because it was more appropriate for my particular scenario. Thanks again!Onitaonlooker
G
0

Had similar issue but while using the terminal and vscode source control. I used this git pull --no-ff and then git push

or change your gitconfig file:

  • code ~/.gitconfig # to see inside the gitconfig file.
  • git config --global pull.rebase false # merge (the default strategy)
  • git config pull.rebase true # rebase
  • git config pull.ff only # fast-forward only

and then a git push

difference between merge and rebase https://www.atlassian.com/git/tutorials/merging-vs-rebasing

Gouge answered 23/5, 2023 at 15:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.