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

Bitbucket - Single commit for all the commit's

I am currently using BitBucket as version control for my project. I see different node (In the image with black dots/multiple commits) of Branch graph on multiple commits. How can I make sure only one node is present on branch graph for all commit I…
Paritosh M
  • 289
  • 2
  • 5
  • 16
0
votes
1 answer

amending a commit to add a file, cause orphan branches

Based on the following git scenario: C0 (master) \ \ C1-------------C5 (develop) \ / \ / C2--C3--C4 (feature) I have a new uncommitted file that I want to add into master as part of commit C0.…
Aleps
  • 21
  • 3
0
votes
3 answers

I have two git commits that appear the same after a pushed amend

I have a git branch that I am working on locally. After editing some code and doing a commit and a push to a remote repo, I noticed that I had an error in my commit message. I used amend to correct this. First I tried to push, but this was not…
Hoytman
  • 1,722
  • 2
  • 17
  • 29
0
votes
1 answer

Amended commits revert to previous commit

I have a repo with master branch. I have patch-sets 1 to 10 amended in a single commit. Now I have amended the 11th patch-set in that commit and pushed the code in gerrit. I want to revert the commit back to 10th commit and push. How do I revert, as…
TechTotie
  • 127
  • 1
  • 15
0
votes
1 answer

Merge changes in ammended commit from remote branch?

I currently have a PR open on a repo where the maintainer prefers to have all PR's as a single commit. This heavily effects my workflow when making changes on request from the maintainer. I have a desktop and laptop that I use to work from. This…
dylanjm
  • 2,011
  • 9
  • 21
0
votes
1 answer

How do I find all commits with a certain message and squash them into the previous commit?

When I've been coding I often use git commit -am to save my work, and occasionally I'll use git commit --amend if I made a mistake in the previous commit. Recently I thought I was being clever and started combining them doing git commit…
personjerry
  • 1,045
  • 8
  • 28
0
votes
1 answer

Amend commit while splitting in rebase

Sometimes I accidentally amend the previous commit with the changes I want to make to the one before that, i.e. HEAD~1. I usually go into rebase interactive mode with git rebase -i, split the commit into two commits, complete the rebase. Then rebase…
Connor Blakey
  • 846
  • 1
  • 7
  • 8
0
votes
3 answers

Change a commit pushed to GitHub... removing files

Git twists my brain. But I think I'm halfway there with this problem. I committed (twice) and pushed to GitHub, but the first commit contained two files that should not have been included. So I have done the following... git reset --hard…
edcincy
  • 321
  • 2
  • 3
  • 14
0
votes
0 answers

How can I GIT REWORD from the command line?

Is there a way to reword a git commit message from command line? Something like git commit --amend --message="New message" Similar as we can change author name via git commit --amend --author="New Author Name "
sandalone
  • 41,141
  • 63
  • 222
  • 338
0
votes
0 answers

Change commit message with original COMMITTER_DATE

I have a GIT repository and would like to change message of one commit. I made following command: git rebase -i HEAD ~ 42 git commit --amend -m "new message" git rebase --continue Unfortunately, then dates of all subsequent commits change. I would…
0
votes
1 answer

Understanding git commit with amend option

let's say i have a file 'A' i have modified the file and pushed it to the repository by the following commands git add A git commit -m "changed A" git push later after i have realised that i need changes in file 'B' so i have modified it and ran…
Shiva Sai
  • 463
  • 4
  • 12
0
votes
1 answer

Git: how to modify the content (not commit message) for the HEAD^^ commit

Suppose I worked on: feature 1: file1 + file3 feature 2: file2 and I have the following commits Commit 2: feature 2 completed. Commit 1: Feature 1 completed. The wrong thing I made is I forget to add the file3 to commit 1. How can add…
zhihuifan
  • 1,093
  • 2
  • 16
  • 30
0
votes
2 answers

git Changing a commit message (amend)

I am in a situation where I would like to edit the commit message of an old, already pushed code. In my case I have , of course, my master branch and several other branches, for example v1.0, v2.0 and v3.0. The commit I want to update its messages…
Anton
  • 41
  • 8
0
votes
1 answer

Git : edit commit message of other parent

I must edit a commit message of a parent of a merge commit (the parent is actually itself a merge). How do I do this ? Here F is my current HEAD, result of the merge of E and D. D is itself the result of the merge of A and C, and D is the commit…
Charles
  • 988
  • 1
  • 11
  • 28
0
votes
3 answers

Automating commit amend procedure

I am finding myself annoyed at having to run the full procedure to amend commits in git and I was wondering which was the best way of automate them. So, instead of doing this: $> git add . $> git commit --amend $> git push -f I'd love to do this $>…
antogilbert
  • 176
  • 2
  • 12
1 2 3
9
10