Questions tagged [git-amend]

Parameter of git-commit command that adds the current staging area to the last commit and allows you to (by default) edit previously used commit message or (if other options were given) reuse it or even discard it and write a new one.

New commit!

Using this option effectively creates new commit! It replaces current tip of the branch, so if you use it on anything that's NOT the tip (checking out a tag or SHA and then amending) you're effectively branching (feel free to check with logs).

It's considered a rough equivalent of

  • soft reset,
  • manual changes
  • and committing on top of ORIG_HEAD.

Trivia

  1. You may also use it to amend a merge commit.
  2. Using --reset-author with --amend you also reset author and author timestamp.

More:

git help commit

146 questions
0
votes
0 answers

How to make Git automatically retain committer date for `git commit --amend`?

I am aware of Git picking up the GIT_COMMITTER_DATE environment variable, but for every amending commit, I have to manually prepend GIT_COMMITTER_DATE="$(git log -1 --pretty=tformat:%cD HEAD)" to the command line. Is there a config option to make…
iBug
  • 35,554
  • 7
  • 89
  • 134
0
votes
0 answers

fixing a commit message that isn't the last commit

I make a mistake in my commit message in GitHub. what I have done I navigated to the directory where I wanted its commit message to change. To make vs code my default editor I ran this: git config --global core.editor "code --wait" afterwards, I ran…
0
votes
1 answer

How do you add to the last commit message when running git commit --amend

not sure if you can do this but I am looking for the Syntax / Placement to add a new message when editing a commit via git commit --amend I am aware that you can overwrite a message via git commit --amend -m ''. In this…
Wally
  • 705
  • 1
  • 9
  • 24
0
votes
1 answer

Local branch and remote branch have diverged after amending commit

I have a feature branch called featureA and I am the only developer who is and will be touching this branch until it gets merged to master branch. My git command history is: committed changes locally made more changes then pushed to remote by…
joana
  • 1
  • 1
0
votes
1 answer

Is it safe to push amend on private branch

Say I am the sole developer working on a branch. I push and immediately see the wrong message which I want to fix with amend. I know when others are working it can easily do a lot of trouble. But if I am 100% sure no one touched the commit and…
zmaten
  • 429
  • 4
  • 16
0
votes
1 answer

git amend: Commit not amended

I see a bit strange behavior with Git. So I have a feature branch locally, say F1, and I add a commit, C1, to it. I push it to repo, get reviews and finally merge to master. So master has my commit C1 on top. Then I realized that some changes in C1…
Mandroid
  • 6,200
  • 12
  • 64
  • 134
0
votes
0 answers

How to amend file in previous to last local commit?

I'm aware of various ways to amend the latest local commit. I'm looking into updating the file in previous to last local commit. Searching SO, I didn't find anything relevant. Is this achievable? If yes how do I do it?
mtk
  • 13,221
  • 16
  • 72
  • 112
0
votes
1 answer

Undo git commit message in 2 different branches (develop and feature) after git push

do not want to break anything in the master branch. I forked a develop branch through below commands git checkout develop git pull upstream develop # pull the updates locally based on the git push origin develop # sync your local develop branch…
0
votes
1 answer

How to revert to a previous version of a commit?

I made some mistakes in my amended commits and would like to revert back to a previous version of the commit. I usually just manually do this by manually recreating the previous state, but I would like to do this in an easier way. This is the commit…
jinkins
  • 25
  • 1
  • 6
0
votes
1 answer

TortoiseGit amend merge commit: "show diff to last commit" checkbox is disabled

I'm trying to commit --amend to a merge commit with TortoiseGit 2.13.0.1. For a repository where the last commit is a merge commit, the "show diff to last commit" checkbox is disabled (greyed) and checked after i check the amend checkbox; it doesn't…
ridilculous
  • 624
  • 3
  • 16
0
votes
1 answer

What to do when force pushing is denied by remote hub?

Okay, so this is a question after the fact, and I just want to know what I should've done so I can avoid this problem in the future. Yes, I realize force pushing is a dangerous command. Yes, I realize git reset HEAD --hard can be a dangerous command…
dylanjm
  • 2,011
  • 9
  • 21
0
votes
2 answers

Prevent git commit --amend from trying to amend an already submitted change?

We are using Gerrit for code reviews. The normal workflow is: git commit run a script to push the commit, which does: git commit --amend, which I think triggers a hook git push Every now and then, I forget to do the commit and I totally mess…
0
votes
0 answers

Reset name and email for commits on GitHub without changing date

Like so many others, I have committed to a repository with the wrong name and email. While there are A LOT of posts and solutions on how to correct these informations and some to preserve the date, I can't find a solution that preserves the date on…
Little Helper
  • 1,870
  • 3
  • 12
  • 20
0
votes
1 answer

How to properly maintain one commit per feature branch strategy in a GIT workflow?

In a project I am working on, we have workflow of one commit per feature branch. If I have not to make any subsequent changes after a commit, then it is fine, but if after a commit, and which has been pushed too to remote, I have to make some…
gitstudent
  • 11
  • 1
0
votes
1 answer

fatal: --author 'First Last example@example.com' is not 'Name ' and matches no existing author

I ran into this error when trying to amend a commit to change the author. git commit --amend --author="First Last example@example.com" fatal: --author 'First Last example@example.com' is not 'Name ' and matches no existing author It is…
Jacob Stern
  • 3,758
  • 3
  • 32
  • 54