Re: modifying the commits before push

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx" \
    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@xxxxxxx"
$ git config --global user.name "Sam Steingold"

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

HTH
    Dirk








--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]