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
1
vote
1 answer

git I forgot to edit a line before commiting and pushing

I decided to integrate a library into my code. I add the library, and change a couple lines of code to start implementing it. It compiles, so I commit and push to the repo. I only realise later that I've missed a line that is still on old code. I…
danielr
  • 130
  • 1
  • 8
1
vote
2 answers

How can I detect whether a git commit is a parent of other commits?

I'm writing a script that makes some trivial changes and then commits them to git. Because these are trivial changes, I want to do git commit --amend whenever I can get away with it -- specifically, when an amend won't "mess up" any other branches'…
Joe White
  • 94,807
  • 60
  • 220
  • 330
1
vote
1 answer

Amend past commit message in Git-Tower

Change the commit message be390538 from "A" to "6" in Git-Tower
Alice Chan
  • 2,814
  • 2
  • 16
  • 16
1
vote
3 answers

What happens when amending an old commit with git?

I don't really understand what happens if I check out an old commit, do some modifications, and commit using git commit --amend. Will that change automatically propagate to future commits? How does it work?
Olivier Verdier
  • 46,998
  • 29
  • 98
  • 90
1
vote
1 answer

git: How to refresh a commit that isn't on top

In my working branch, I have three dependent patches. All of them not merged. How can i add new changes to ? Currently here is how I am doing it. git stash git reset --hard HEAD~1 git stash…
Sandeep
  • 18,356
  • 16
  • 68
  • 108
1
vote
1 answer

Amended pushed commit - how to recover sync without force?

I amended a pushed commit. Now can't push to git repo. I do not want to push with -f key because it will make a lot of problems to other people. Currently I see only one solution: git clone write changed files over from a backup copy make a new…
Paul
  • 25,812
  • 38
  • 124
  • 247
1
vote
1 answer

How can I change the displayed commit message on Github?

I pushed a commit with one changed file to Github. This was the first (and only) commit to this repo, which was forked from another user. I then changed the commit message using git commit --amend -m "New message." git push --force origin master.…
user3065699
  • 329
  • 1
  • 8
1
vote
1 answer

How to update the head of a branch when one of its ancestor commits was updated in another branch

master ---A---B \ feature1 C There are two branches like the above. After committed C, I amended revision B using "git commit --amend". Is it possible for revision C to pick up the changes I made to B?
Shuo
  • 4,749
  • 9
  • 45
  • 63
1
vote
1 answer

How do I put the HEAD back to its previous position after reset?

I wanted to amend a commit message from two commits ago, so I did: $ git reset --soft HEAD~1 $ git commit --amend -m "Revised commit message" Now how do I get HEAD back to where it was before I git reset?
Big McLargeHuge
  • 14,841
  • 10
  • 80
  • 108
1
vote
4 answers

How do I edit an incorrect commit message in Git without including any staged modifications?

If I have staged some changes, and in the process notice an error in my previous (and un-pushed) commit message, is there a way to amend the commit without folding in my staged changes? I see various options on the man page for git-commit that…
Rhubbarb
  • 4,248
  • 6
  • 36
  • 40
1
vote
1 answer

A repo-wide rebase of a commit

Consider this line of commits. foo: a => b => c => d \bar: => e => f => g I start out with branch foo and occasionally create the new branch bar from foo. Now, as I am working on commit h in branch bar, I realize that I made a…
Niels B.
  • 5,912
  • 3
  • 24
  • 44
1
vote
0 answers

Git - Problems with Detached Head, Amending Commits, and Being Behind when Pushing?

Our team is using git submodules, but we run into some errors with pulling, which tells us that we are behind even though we recently updated (and there have been no remote commits / pushes since). This happens in two scenarios: with detached HEAD…
eacousineau
  • 3,457
  • 3
  • 34
  • 37
1
vote
1 answer

Git commit amend in aptana studio 3?

I just noticed when I tried to amend a commit that there is no git commit amend function in Aptana Studio 3. Is that correct or am I missing something? If it is indeed not there, does anyone in the community know whether it's ever going to be added…
Jamie Carl
  • 1,206
  • 14
  • 22
1
vote
1 answer

How do I fix incorrect pushed commit in Git?

I was so dumb that I committed and pushed it to the server and found out that the commit message was wrong. So I used --amend to fix the comment. But now I can't push to the server anymore :S What to do?
Spoeken
  • 2,549
  • 2
  • 28
  • 40
0
votes
2 answers

git --amend in external editor

I am working on learning how to use git and the section I am on now is using --amend. When I run this in terminal it opens up TextMate for me to change the message. I change the message and then save. I go back to terminal and nothing has…
pertrai1
  • 4,146
  • 11
  • 46
  • 71