V
V
Vlad2021-12-26 14:08:30
git
Vlad, 2021-12-26 14:08:30

Why can't I push to Github after 'git commit --amend --no-edit'?

I noticed that there was a gitignor on the images, fixed it, added it to the index and committed it using the "git commit --amend --no-edit" amend to merge the indexed changes with the previous commit without creating a new commit. Further events develop as follows:

PS D:\OSPanel\domains\mysite> git log --oneline
75fb9c0 (HEAD -> main) Integrating Webpack into Gulp
43db754 (webpack) Integrating Webpack into Gulp
9b8eb7e the first commit in the new repository of the old project
PS D:\ OSPanel\domains\mysite> git push origin
To github.com:myusername/mysite.git
! [rejected] main -> main (non-fast-forward)
error: failed to push some refs to 'github.com:myusername/mysite.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (eg
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
PS D:\OSPanel\domains\mysite> git branch
* main
webpack
PS D:\OSPanel\domains\mysite>


Why updates are rejected, pointer behind, how to push after --no-edit amend?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-12-26
@Vextor-ltd

Either you have already pushed the commit that you are changing ("changed" commit is actually just another commit with a different hash, commits cannot be changed, that's their essence), or someone else has already pushed something of their own into the branch.
In the first case, do a push with a flag --force-with-leaseto rewrite the commit, in the second case, first make a pool and pull the changes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question