GitHub refuses a push that would throw away commits it has and you don't. That happens when a teammate pushed first:
text
git push
To https://github.com/monster-market/blog.git
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'https://github.com/monster-market/blog.git'
hint: Updates were rejected because the remote contains work that you do not
hint: have locally. This is usually caused by another repository pushing to
hint: the same ref. If you want to integrate the remote changes, use
hint: 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.Nothing is broken. Your push wasn't a fast-forward of GitHub's main. The fix is the one the hint gives: pull their work into yours, then push the result.
text
git pull
hint: Waiting for your editor to close the file...
Merge made by the 'ort' strategy.
post.md | 1 +
1 file changed, 1 insertion(+)
From https://github.com/monster-market/blog.git
af906b0..00f8d2c main -> origin/main
git push
To https://github.com/monster-market/blog.git
00f8d2c..825877f main -> mainOn a team, you'll see this rejection most days. Pull, check the result, push.
Objectives
- Get your commit onto GitHub.
- Keep Sam's commit.