Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually sync branch when Bitbucket fails

Tags:

git

I know how to sync branch with master. I do this so:

git checkout target-branch
git merge master
# resolve conflicts if any and commit
git push

I am trying to figure it out what BitBucket suggests me when automatic sync failed because of conflicts. BitBucket suggests me:

git checkout 326907c583f7
# Note: This will create a detached head!
git merge remotes/origin/master

What's the point to create detached head? I does not make sense to me. Is it bug on Bitbucket side or I am missing something?

like image 872
stz184 Avatar asked Jan 11 '16 14:01

stz184


1 Answers

In case BitBucket can't sync branches for you, that you have some conflicts with your branch changes and the destination branch.

You can use git rebase to sync your local branch and later, push changes.

Assuming that you want to sync with the master branch, you can do these next steps:

First, update your local master branch.

git fetch origin master:master

Then, sync changes of your branch with the master branch

git rebase master

If you have conflicts, you will receive a message with more information about them. Make the necessary changes and use:

git rebase --continue

There you can receive a new conflict, in that case, repeat the previous operation. If not, you can push changes to the remote repository.

Cause you have changes the history with the git rebase command, you will need to force your push.

git push -f
like image 185
Nurio Fernández Avatar answered Sep 27 '22 16:09

Nurio Fernández