2

I had to do some work on my laptop on the dev branch, which I then pushed.

Later, I did some work on the desktop, also on dev, and when I went to push it, it failed with a message "fetch first". I did a pull and merged, then pushed.

It ended up looking like this:

enter image description here

As you can see, I get a split in the dev branch with a merge. Obviously, this would have been prevented if I had remembered to fetch first before my commit.

But at the point where bitbucket rejected the push, is there anything I could have done to prevent the merge and get a nice straight timeline?

Sarke
  • 2,805
  • 2
  • 18
  • 28
  • 5
    `git pull --rebase` would be what you're looking for (instead of `fetch`) – Whymarrh Aug 15 '17 at 00:16
  • 3
    Possible duplicate of [When do you use git rebase instead of git merge?](https://stackoverflow.com/questions/804115/when-do-you-use-git-rebase-instead-of-git-merge) – Whymarrh Aug 15 '17 at 00:17
  • 2
    See also [this answer in particular](https://stackoverflow.com/a/804178/1267663) which describes the difference between merging (what you did) and rebasing (what you describe as your desired "nice straight timeline") – Whymarrh Aug 15 '17 at 00:18
  • Related: [How to make Git pull use rebase by default for all my repositories?](https://stackoverflow.com/q/13846300/1542723) – Ferrybig Aug 15 '17 at 08:02

0 Answers0