Reputation: 393
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.
Upvotes: 9
Views: 14279
Reputation: 11
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
# rebasegit config pull.ff only
# fast-forward onlyand then a git push
difference between merge and rebase https://www.atlassian.com/git/tutorials/merging-vs-rebasing
Upvotes: 0
Reputation: 793
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.
Upvotes: 9
Reputation: 100003
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.
Upvotes: 1