'git commit --amend --no-edit
I had already pushed some changes to a remote. Now I need to push some other changes related to the commit that I already pushed, which should be in that commit but somehow are not. I can do this simply by pushing the changes with a new commit but suddenly I found --no-edit
flag with --amend
I need to push the new changes but I need a single commit having the old and new changes.
Is git commit --amend --no-edit
is something which I need?
Solution 1:[1]
Generally, it's best to avoid rewriting the history, and just add a new commit as hyde suggested.
If you really need to overwrite the history, make sure to use --force-with-lease
when you push.
Solution 2:[2]
Yes, the git commit --amend --no-edit
is the thing that I am looking for.
git add .
(Add the added and modified files)git commit --amend --no-edit
git push --force-with-lease <remote> <branch>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Anders Lundbäck |
Solution 2 | Piyush Chaudhary |