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
2
votes
2 answers

Is it possible to make a git commit non-amendable?

Is there a way to protect a given git commit from being amended? All I can think to do is to write a pre-commit hook to check the SHA against a list of 'non-amendable' SHAs. Does anyone know of a standard/better way? Thanks.
user1675642
  • 747
  • 2
  • 5
  • 15
2
votes
2 answers

why git commit --amend make confliction happened? that is quite strange

* 84b134d - (HEAD, origin/lab_master, lab_master) comment macro defination which is protent to be a fun |\ | * 735d88f - add small script to ease ctag related option (13 minutes ago) * | 6623a94 - add small script to ease ctag related option (4…
hugemeow
  • 7,777
  • 13
  • 50
  • 63
1
vote
2 answers

Can I decide in Git that the last commit is pushed?

I have a workflow as following: during development, I often commit (locally) regardless whether I have reached any milestone, just for backing up and being able to recover if development goes towards a bad direction, or, for example, all the times…
Gyula Sámuel Karli
  • 3,118
  • 2
  • 15
  • 18
1
vote
1 answer

Why I am getting a branch conflict every time I try to amend/commit to my personal repo?

I am using GitHub for the first time and I've spent past few days trying to wrap my head around basic git functionality and commands. Currently, my repository is private–I am the only person using it and pushing commits. However, I want to ensure…
DAK
  • 116
  • 1
  • 10
1
vote
2 answers

git: getting rid of previous commit so that you can amend the one before

what happened: change1, git commit, git push, change2, git commit what should have happened: change1, git commit, git push, change2, git commit --amend It's not important that I retain change2, but it is important that I am able to amend the…
mbarrows
  • 555
  • 5
  • 15
1
vote
1 answer

How to access amended commit in Jenkins?

I use a custom trigger that scans for changes in repository and starts the builds when needed. It is a Jenkinsfile with some helper gradle scripts on the side. The core of functionality that checks the changes is git diff. It takes…
misty
  • 123
  • 13
1
vote
1 answer

git: change a commit and delete the old one

I would like to modify the current git commit and remove its previous form. In other words the "old" current commit has to disapper and it is replaced by the "new" one with the same commit message. At the moment I am doing: git add . git commit…
yellowhat
  • 429
  • 6
  • 17
1
vote
2 answers

Amend previous commit with no change to commit message

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…
Piyush Chaudhary
  • 183
  • 2
  • 12
1
vote
1 answer

why does github show current date instead of real date of an ammended commit?

I amended a commit in a github repository (wrong version in a Changelog file) some days later after the commit was pushed. When I do a git log I see that the amended commit still has the date of the original commit as it should, but in github it…
Juancho
  • 629
  • 7
  • 17
1
vote
1 answer

Cannot git merge because git commit --amend

In master branch, I have the Initial Commit pushed gitlab After that I create a new branch called "branchA" I rename the initial commit with git commit --amend -am Initial Commit v2 and do some modif and commit it In this example, you can see…
qsgfesqk
  • 43
  • 2
1
vote
1 answer

How can i revert a git commit --amend -m without losing my original hashcode and the code i supposed to commit?

I need to revert a wrong git commit --amend -m did git commit without -m did git commit --amend -m "commit message" git commit --amend -m "commit message" changed my previous commit instead of the one i supposed to commit. is it possible to revert…
1
vote
1 answer

Recover commit lost during commit amend

I've made a mistake I guess Yesterday I created a new branch (feature/crud-suppliers), then yesterday and today I worked on that branch. 30 minutes ago, after I finished my changes I added the files modified and did a git commit --amend --no-edit…
alessandro buffoli
  • 658
  • 2
  • 10
  • 29
1
vote
1 answer

Git commit with broken date

I've got an issue with a commit in a Git repo (It's big, and old), the commit in question was apparently committed on 1 Jan 2138, which is clearly wrong. As far as I know it should be 1st Oct 2019. The commit is on remote and there is a-lot commits…
Devan
  • 41
  • 5
1
vote
0 answers

GIT: How to edit/reword a commit message, while keeping the fastforward history of branches

I have a fast-forwarded repo history with branches, representing server upgrade states. branch2 | commit4 | commit3 | branch1 | commit2 | commit1 | initial commit If I rebase from commit1 to reword the commit2 message, then after rebase I will have…
klor
  • 1,237
  • 4
  • 12
  • 37
1
vote
1 answer

Sync other branch when amending commit in current branch

I have to branches, A and B: 1-2-3 ^ ^ A B Say I want to amend commit 2, so I checkout branch A and do git commit --amend. Now my graph looks like this: 1--2' [A] \-2-3 [B] Is there a way to also automatically update branch B (in case…
T-Rex96
  • 355
  • 4
  • 15