All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dirk Süsserott" <newsletter@dirk.my1.cc>
To: git@vger.kernel.org, sds@gnu.org
Subject: Re: modifying the commits before push
Date: Wed, 18 Jan 2012 21:18:34 +0100	[thread overview]
Message-ID: <4F17291A.8020600@dirk.my1.cc> (raw)
In-Reply-To: <87wr8o3nq0.fsf@gnu.org>

Am 18.01.2012 18:49 schrieb Sam Steingold:
> Hi,
> I am trying to push:
> $ git status
> # On branch master
> # Your branch is ahead of 'origin/master' by 4 commits.
> #
> nothing to commit (working directory clean)
> $
> but `git push` fails with this:
> 
> remote: ERROR: Rejecting update because this commit email is not from ZZZ
> 
> What I need to do is
> - modify the 4 commits with a different e-mail and do `git push` again
> - make sure that all my commits in this repo are done with the correct e-mail
> 
> how do I do this?
> 
> thanks!
> 


Hi Sam,

to modify the last 4 commits you can use git filter-branch (see the
manpage):

$ git checkout master
$ git filter-branch --env-filter \
   'GIT_COMMITTER_EMAIL="sds@gnu.org" \
    GIT_COMMITTER_NAME="Sam Steingold"' \
   HEAD~4..HEAD

It should tell you that it rewrites 4 commits. The original tree is
saved under original/refs/heads/master. If sth. went wrong, reset your
master to that point (easiest with gitk, it's steel blue). If it worked,
you can delete the original/refs/heads/master like so:

$ git for-each-ref --format="%(refname)" \
    refs/original/ | xargs -n 1 git update-ref -d

Note: Whether it worked or not, remove the original refs afterwards,
because a second run of git filter-branch will fail if there's already
an "original" tree.

To change your address for future commits configure it in .gitconfig in
your $HOME (--global) or on a per repo basis in .git/config (--local):

$ git config --global user.email "sds@gnu.org"
$ git config --global user.name "Sam Steingold"

Or use git gui for this step (Edit -> Options).

HTH
    Dirk

  reply	other threads:[~2012-01-18 20:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-18 17:49 modifying the commits before push Sam Steingold
2012-01-18 20:18 ` Dirk Süsserott [this message]
2012-01-18 21:47   ` Sam Steingold
2012-01-18 22:01     ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F17291A.8020600@dirk.my1.cc \
    --to=newsletter@dirk.my1.cc \
    --cc=git@vger.kernel.org \
    --cc=sds@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.