Search code examples
gitgitkraken

Beginner Git Question: Does push update the remote branch to equal the local branch?


I am very new to git, and very confused. Note that I am using a gui (gitKraken) because I was getting even more perplexed by the command line.

I squashed two commits then pushed, expecting the remote branch to update to reflect this. I ended up with my local and remote branch looking like they merged, ie, it wasn't linear. Can someone please explain how I should've gone about it?


Solution

  • I don't know Gitkraken. But I do know that if you squash two commits, and one of them was already pushed, now you cannot push at all, because now the remote has a commit that you don't have (you squashed it). Therefore the only way to proceed is to pull (meaning merge) the remote branch before pushing. Maybe Gitkraken is smart enough to know that so it did that?

    So if that's what happened, the takeaway message for you would be: Don't try to rewrite history that you've already pushed. It will end badly.