David Y.
—When attempting to push local commits to a remote repository, I receive the following error:
! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/REDACTED.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
How do I resolve this error and push my changes?
This error generally occurs if new commits have been pushed to the repository since our last pull. For example, let’s say that Alice and Bob both pull the repository at commit A. Alice makes changes and creates commit B, which she then pushes. Bob also makes changes, creating commit C, but when he tries to push this commit, he receives the error above because his repository history does not contain Alice’s commit B.
To fix this, Bob must pull Alice’s changes and integrate them into his repository’s history. He can do this using the following git pull
command:
git pull --rebase
The --rebase
flag will tell git pull
to fetch the upstream version of the current branch (i.e. the one with commits A and B) and replay the changes made in commit C on top of it.
Once this is done, Bob can run git push
again.
Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.
SEE EPISODESConsidered “not bad” by 4 million developers and more than 100,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.
Here’s a quick look at how Sentry handles your personal information (PII).
×We collect PII about people browsing our website, users of the Sentry service, prospective customers, and people who otherwise interact with us.
What if my PII is included in data sent to Sentry by a Sentry customer (e.g., someone using Sentry to monitor their app)? In this case you have to contact the Sentry customer (e.g., the maker of the app). We do not control the data that is sent to us through the Sentry service for the purposes of application monitoring.
Am I included?We may disclose your PII to the following type of recipients:
You may have the following rights related to your PII:
If you have any questions or concerns about your privacy at Sentry, please email us at compliance@sentry.io.
If you are a California resident, see our Supplemental notice.