0

I am not quite sure how to describe my issue, I think the title sums it up though. This is all based in SourceTree and BitBucket if that makes a difference. These questions sound similar on the face of it, but don't answer this.

I have been working on Branch A and Branch B today, commiting changes during the day ready to push at the end of the day.

Someone else has been working on Branch B today also, so before I pushed my changes, I pulled theirs. So with Branch B checked out, the number of commits to pull was 4, and the number to push was 2, but after doing the pull, the pull number went up (can't remember the exact number) and the number of commits to push went up as well, to 18. So I pulled again and then pushed, thinking they were automatic conflict resolutions, only to then discover one of the items was a merge from Branch A into Branch B - really not what I wanted.

This isn't the first time I have had this issue, but the first time I thought I must have done something by accident, this time I know for sure I haven't.

"Commit merged changes automatically" was checked, is there anyway this could have caused it? Have I done something wrong here? What could have caused this?

tim.baker
  • 3,109
  • 6
  • 27
  • 51
  • Of course you'll have the merge commit if the other developer merged and you pulled. What did you expect? The thing you did wrong was to pull without knowing what you were pulling, and then push without reviewing what you pulled. – ChrisGPT was on strike Jun 11 '17 at 02:44
  • @Chris the merge commit is not wrong, I agree with you entirely, that's what should happen. But there was an additional merge with Branch A and B - not local and origin of the same branch – tim.baker Jun 11 '17 at 08:23
  • 1
    In that case I think you're going to have to give us more detail. Personally, I can't visualize your situation. An annotated commit graph would be a good start. – ChrisGPT was on strike Jun 11 '17 at 11:25
  • @Chris Thanks, I have had a look at it today and being unable to replicate it. It is working exactly as I thought, and you are thinking it should. I am fairly sure that SourceTree on Windows is buggy as this wouldn't be the first oddity. Moved over to GitKraken and I'm doing the same thing, but no issues! Thanks – tim.baker Jun 12 '17 at 14:25

2 Answers2

0

I never really got an answer to this, but thought I would post in case someone else comes across this.

Essentially the issue was SourceTree. We have had several issues like this with the program and have abandoned it as a result - since using GitKraken we have had no issues. Furthermore GitKraken is much better at doing things like reversing commits so generally better all round.

tim.baker
  • 3,109
  • 6
  • 27
  • 51
-1

When you do a git pull it is supposed to merge automatically. Because, git pull is basically a composition of git fetch and git merge. Please have a look on merge and fetch documentation.

There is a good way of avoiding such kind of issues.

  1. Commit local changes $git commit -m message
  2. Rebase and sync with server $git pull --rebase
  3. Push gently $git push origin head:refs/for/branchname
Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256