[RUBY] I got an error and couldn't push! !! [error: failed to push some refs to]

● Phenomenon I get an error and can't push

● Error details error: failed to push some refs to "~~"

● What is the cause? Since the conflict was fixed on git lab, There is a difference between the commit history on the remote and the commit history on the local, causing an error.

The situation is as follows.

■ Local Commit history B (review corrections) Commit history 3 Commit history 2 Commit history 1

■ Remote Commit history A (conflict resolution) Commit history 3 Commit history 2 Commit history 1

● What should I do?

This time, I solved it by the following procedure. (1) Copy the local [sample_branch] that has been modified and create [sample_branch_copy] ② Delete the local [sample_branch] (3) Reflect [sample_branch] on the remote locally (acquire commit history A that resolves conflicts) ④ Extract the correction work from the copied [sample_branch_copy] ⑤ The extracted work contents are additionally reflected in the newly reflected local [sample_branch]. ⑥ Commit and push [sample_branch] again

● Operation commands

git branch sample_branch_copy
#Make a copy

git branch -d sample_branch
#Delete local branch

git fetch
#Reflect remote branch locally(Remote sample_Get branch)

Branch name: sample_branch_copy


git reset --soft HEAD^
#Uncommit and return to working state(Canceling a straight line commit)

git stash
#Take out the modified work

Branch name: sample_branch


git stash pop
#Reflect the corrected work contents
git branch
git log
#Always check the status of branch commands with the above command

● To prevent future errors,

In this case, it happened because I fixed the conflict on git lab. Therefore, it is possible to avoid it by fixing the conflict locally in the future.

Recommended Posts

I got an error and couldn't push! !! [error: failed to push some refs to]
What to do if you get the error Couldn't find Item without an ID
I got an error and couldn't push! !! [error: failed to push some refs to]
Find out about instance methods and self
I got an error when using nextInt, nextLine and substring.
[Mockito] 3.2.4 → 3.3.x, but I got an error (Iketenai)
I got an error when I ran rake routes.
When registering a new user, I got an error called ActiveRecord :: NotNullViolation and how to deal with it.
I built a CentOS 8 environment with Vagrant and tried to sync_folder, but I got an error, so I solved it.
I got an error "undefined method` create'" in RSpec
When I bcrypt with node + docker, I got an error
I got an error when trying to install sbt to build a Scala development environment
I can deploy to heroku, but I get an error and can't open it [Cause: MySQL]
I got an error! * There is no interactive request template
I want to push an app made with Rails 6 to GitHub
When I push to Heroku, I get angry with Precompiling assets failed.
I got an IllegalAccessError when trying to use PowerMock with JUnit
Processing to issue an error message
Add gem'rails-i18n','~> 6.0.0' and what to do if bundle install gives an error
I get an error with bundle install and puma cannot be installed.
What to do and how to install when an error occurs in DXRuby 1.4.7
I want to display an error message when registering in the database
I can deploy Heroku, but I get an error and can't open it
When I tried to start GlassFish, I got an internal error while "Publishing to GlassFish 4.0 on localhost ...". What to do when it becomes
I tried to use docker with jetson jetpack4.3 but got an error (docker: Error response from daemon: OCI runtime create failed: container_linux.go: 345: starting container process caused ...)