Reputation: 313
I had already pushed some changes to a remote. Now I need to push some other changes which should be in that previously pushed commit but somehow are not. I can do this simply by pushing the changes with a new commit but just now I have found the --no-edit
flag and --amend
If 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
going to achieve that?
Upvotes: 1
Views: 9242
Reputation: 313
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>
Upvotes: 6
Reputation: 98
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.
Upvotes: 3