— git, rebase, force push, github, code snippet, today-i-learned — 1 min read
The context is actually continuation of my rebasing effort, because the previous commits were already pushed to remote. So if I rebased, then this would mean the timeline would diverge, so I didn't want that. Since it was just the beginning of my project, I figured I could get away with a forceful push.
Had a bad experience with force push, at my first real job, in my first week there. We lost 2 months' worth of work because I did that. As a "learning" opportunity, I was asked to use SourceTree for a bit to really understand what I was doing. Spoiler, I still don't know what I was trying to do at the time, but I guess it was due to merging conflicts. Now I'm more careful with conflicts, and check it properly.
That said, this is why I chose the safest option:
1git push <remote> <branch> --force-with-lease