How can I remove my private email from the `git log --all --format="%aN ` output?












3















I was going through this article: https://help.github.com/articles/changing-author-info/.



Note the warning at the top of the article: "Warning: This action is destructive to your repository's history. If you're collaborating on a repository with others, it's considered bad practice to rewrite published history. You should only do this in an emergency." 'Tis a pity that there doesn't seem to be a way to rewrite history to only rewrite the email and/or author name. Kudos to GitHub for providing a vector for unsolicited emails, without being able to change this! It seems like the next best option is to change emails, notify important contacts, and not enable forwarding from the old email to the new one. If you choose to go with this option then you may also want to enable an auto-response only to people in your contacts (a feature that is available in Gmail, not sure about other email providers), e.g.:




Due to getting too many emails, including many unsolicited ones, I
have changed my email address and no longer actively monitor this one.
If you wish to contact me about something that is very likely to be of
interest to me, then please contact me via <insert some communication medium, e.g. a contact form on a page on your website with social media links or your https://about.me page>




I'll reproduce the steps here:



Run:



# It is simplest if you use a repo that you have
# already contributed to.
git clone --bare https://github.com/user/repo.git
cd repo.git


Add a file (call it say, git-author-rewrite.sh or gar.sh) to the repo.git directory with the following script, replacing OLD_EMAIL, CORRECT_NAME and CORRECT_EMAIL with the appropriate values:



#!/bin/sh

# gar is short for git-author-rewrite

git filter-branch -f --env-filter '

OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --exclude="refs/original" --all
# originally this had `-- --branches --tags`, but has been revised as
# per the answer below, and a -f also added.


Add an exec permission to the script: chmod +x gar.sh. Run the script: ./gar.sh.



After running the script and checking the history in all branches with git log --all --format="%aN <%ae>" | sort -u it still shows my private email address. I get spammy emails (where in some cases people have even mentioned "I have noticed you contributed to X repo"), and have been careful to avoid listing my email publicly (with the exception of commit histories up until I changed to not use my private email on GitHub). So I need to run this script in all branches. However, my private email has been removed from the output if the --all option is removed.



The output of the script included a few "WARNING: Ref refs/heads/some_branch unchanged" lines although has many "Ref 'refs/heads/some-branch-name' was rewritten".



How can I remove my private email from the git log --all --format="%aN <%ae>" | sort -u output? Edit: use git log --exclude="refs/original" --all --format="%aN <%ae>" | sort -u as suggested in the first answer.



I'm not sure why, but you need to run the script twice, since after running the above log command after running the script once it still outputs my private email. I'm guessing that the second run overwrites the backup and the log command isn't properly excluding all backups.



TODO: try git log --exclude="refs/original/*" --all --format="%aN <%ae>" | sort -u



Edit: after pushing changes to the origin remote (which was even with the upstream) it is changing files, and I'm not sure why, nor how to fix it yet.



I have also sent feedback to GitHub on this, and will update with their reply. However, maybe someone here might be able to help me.










share|improve this question

























  • Please take some time to read the help page, especially the sections named "What topics can I ask about here?" and "What types of questions should I avoid asking?". And more importantly, please read the Stack Overflow question checklist. You might also want to learn about Minimal, Complete, and Verifiable Examples.

    – Clijsters
    Nov 23 '18 at 8:07
















3















I was going through this article: https://help.github.com/articles/changing-author-info/.



Note the warning at the top of the article: "Warning: This action is destructive to your repository's history. If you're collaborating on a repository with others, it's considered bad practice to rewrite published history. You should only do this in an emergency." 'Tis a pity that there doesn't seem to be a way to rewrite history to only rewrite the email and/or author name. Kudos to GitHub for providing a vector for unsolicited emails, without being able to change this! It seems like the next best option is to change emails, notify important contacts, and not enable forwarding from the old email to the new one. If you choose to go with this option then you may also want to enable an auto-response only to people in your contacts (a feature that is available in Gmail, not sure about other email providers), e.g.:




Due to getting too many emails, including many unsolicited ones, I
have changed my email address and no longer actively monitor this one.
If you wish to contact me about something that is very likely to be of
interest to me, then please contact me via <insert some communication medium, e.g. a contact form on a page on your website with social media links or your https://about.me page>




I'll reproduce the steps here:



Run:



# It is simplest if you use a repo that you have
# already contributed to.
git clone --bare https://github.com/user/repo.git
cd repo.git


Add a file (call it say, git-author-rewrite.sh or gar.sh) to the repo.git directory with the following script, replacing OLD_EMAIL, CORRECT_NAME and CORRECT_EMAIL with the appropriate values:



#!/bin/sh

# gar is short for git-author-rewrite

git filter-branch -f --env-filter '

OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --exclude="refs/original" --all
# originally this had `-- --branches --tags`, but has been revised as
# per the answer below, and a -f also added.


Add an exec permission to the script: chmod +x gar.sh. Run the script: ./gar.sh.



After running the script and checking the history in all branches with git log --all --format="%aN <%ae>" | sort -u it still shows my private email address. I get spammy emails (where in some cases people have even mentioned "I have noticed you contributed to X repo"), and have been careful to avoid listing my email publicly (with the exception of commit histories up until I changed to not use my private email on GitHub). So I need to run this script in all branches. However, my private email has been removed from the output if the --all option is removed.



The output of the script included a few "WARNING: Ref refs/heads/some_branch unchanged" lines although has many "Ref 'refs/heads/some-branch-name' was rewritten".



How can I remove my private email from the git log --all --format="%aN <%ae>" | sort -u output? Edit: use git log --exclude="refs/original" --all --format="%aN <%ae>" | sort -u as suggested in the first answer.



I'm not sure why, but you need to run the script twice, since after running the above log command after running the script once it still outputs my private email. I'm guessing that the second run overwrites the backup and the log command isn't properly excluding all backups.



TODO: try git log --exclude="refs/original/*" --all --format="%aN <%ae>" | sort -u



Edit: after pushing changes to the origin remote (which was even with the upstream) it is changing files, and I'm not sure why, nor how to fix it yet.



I have also sent feedback to GitHub on this, and will update with their reply. However, maybe someone here might be able to help me.










share|improve this question

























  • Please take some time to read the help page, especially the sections named "What topics can I ask about here?" and "What types of questions should I avoid asking?". And more importantly, please read the Stack Overflow question checklist. You might also want to learn about Minimal, Complete, and Verifiable Examples.

    – Clijsters
    Nov 23 '18 at 8:07














3












3








3


1






I was going through this article: https://help.github.com/articles/changing-author-info/.



Note the warning at the top of the article: "Warning: This action is destructive to your repository's history. If you're collaborating on a repository with others, it's considered bad practice to rewrite published history. You should only do this in an emergency." 'Tis a pity that there doesn't seem to be a way to rewrite history to only rewrite the email and/or author name. Kudos to GitHub for providing a vector for unsolicited emails, without being able to change this! It seems like the next best option is to change emails, notify important contacts, and not enable forwarding from the old email to the new one. If you choose to go with this option then you may also want to enable an auto-response only to people in your contacts (a feature that is available in Gmail, not sure about other email providers), e.g.:




Due to getting too many emails, including many unsolicited ones, I
have changed my email address and no longer actively monitor this one.
If you wish to contact me about something that is very likely to be of
interest to me, then please contact me via <insert some communication medium, e.g. a contact form on a page on your website with social media links or your https://about.me page>




I'll reproduce the steps here:



Run:



# It is simplest if you use a repo that you have
# already contributed to.
git clone --bare https://github.com/user/repo.git
cd repo.git


Add a file (call it say, git-author-rewrite.sh or gar.sh) to the repo.git directory with the following script, replacing OLD_EMAIL, CORRECT_NAME and CORRECT_EMAIL with the appropriate values:



#!/bin/sh

# gar is short for git-author-rewrite

git filter-branch -f --env-filter '

OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --exclude="refs/original" --all
# originally this had `-- --branches --tags`, but has been revised as
# per the answer below, and a -f also added.


Add an exec permission to the script: chmod +x gar.sh. Run the script: ./gar.sh.



After running the script and checking the history in all branches with git log --all --format="%aN <%ae>" | sort -u it still shows my private email address. I get spammy emails (where in some cases people have even mentioned "I have noticed you contributed to X repo"), and have been careful to avoid listing my email publicly (with the exception of commit histories up until I changed to not use my private email on GitHub). So I need to run this script in all branches. However, my private email has been removed from the output if the --all option is removed.



The output of the script included a few "WARNING: Ref refs/heads/some_branch unchanged" lines although has many "Ref 'refs/heads/some-branch-name' was rewritten".



How can I remove my private email from the git log --all --format="%aN <%ae>" | sort -u output? Edit: use git log --exclude="refs/original" --all --format="%aN <%ae>" | sort -u as suggested in the first answer.



I'm not sure why, but you need to run the script twice, since after running the above log command after running the script once it still outputs my private email. I'm guessing that the second run overwrites the backup and the log command isn't properly excluding all backups.



TODO: try git log --exclude="refs/original/*" --all --format="%aN <%ae>" | sort -u



Edit: after pushing changes to the origin remote (which was even with the upstream) it is changing files, and I'm not sure why, nor how to fix it yet.



I have also sent feedback to GitHub on this, and will update with their reply. However, maybe someone here might be able to help me.










share|improve this question
















I was going through this article: https://help.github.com/articles/changing-author-info/.



Note the warning at the top of the article: "Warning: This action is destructive to your repository's history. If you're collaborating on a repository with others, it's considered bad practice to rewrite published history. You should only do this in an emergency." 'Tis a pity that there doesn't seem to be a way to rewrite history to only rewrite the email and/or author name. Kudos to GitHub for providing a vector for unsolicited emails, without being able to change this! It seems like the next best option is to change emails, notify important contacts, and not enable forwarding from the old email to the new one. If you choose to go with this option then you may also want to enable an auto-response only to people in your contacts (a feature that is available in Gmail, not sure about other email providers), e.g.:




Due to getting too many emails, including many unsolicited ones, I
have changed my email address and no longer actively monitor this one.
If you wish to contact me about something that is very likely to be of
interest to me, then please contact me via <insert some communication medium, e.g. a contact form on a page on your website with social media links or your https://about.me page>




I'll reproduce the steps here:



Run:



# It is simplest if you use a repo that you have
# already contributed to.
git clone --bare https://github.com/user/repo.git
cd repo.git


Add a file (call it say, git-author-rewrite.sh or gar.sh) to the repo.git directory with the following script, replacing OLD_EMAIL, CORRECT_NAME and CORRECT_EMAIL with the appropriate values:



#!/bin/sh

# gar is short for git-author-rewrite

git filter-branch -f --env-filter '

OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --exclude="refs/original" --all
# originally this had `-- --branches --tags`, but has been revised as
# per the answer below, and a -f also added.


Add an exec permission to the script: chmod +x gar.sh. Run the script: ./gar.sh.



After running the script and checking the history in all branches with git log --all --format="%aN <%ae>" | sort -u it still shows my private email address. I get spammy emails (where in some cases people have even mentioned "I have noticed you contributed to X repo"), and have been careful to avoid listing my email publicly (with the exception of commit histories up until I changed to not use my private email on GitHub). So I need to run this script in all branches. However, my private email has been removed from the output if the --all option is removed.



The output of the script included a few "WARNING: Ref refs/heads/some_branch unchanged" lines although has many "Ref 'refs/heads/some-branch-name' was rewritten".



How can I remove my private email from the git log --all --format="%aN <%ae>" | sort -u output? Edit: use git log --exclude="refs/original" --all --format="%aN <%ae>" | sort -u as suggested in the first answer.



I'm not sure why, but you need to run the script twice, since after running the above log command after running the script once it still outputs my private email. I'm guessing that the second run overwrites the backup and the log command isn't properly excluding all backups.



TODO: try git log --exclude="refs/original/*" --all --format="%aN <%ae>" | sort -u



Edit: after pushing changes to the origin remote (which was even with the upstream) it is changing files, and I'm not sure why, nor how to fix it yet.



I have also sent feedback to GitHub on this, and will update with their reply. However, maybe someone here might be able to help me.







git






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 '18 at 1:02







James Ray

















asked Nov 22 '18 at 23:49









James RayJames Ray

1799




1799













  • Please take some time to read the help page, especially the sections named "What topics can I ask about here?" and "What types of questions should I avoid asking?". And more importantly, please read the Stack Overflow question checklist. You might also want to learn about Minimal, Complete, and Verifiable Examples.

    – Clijsters
    Nov 23 '18 at 8:07



















  • Please take some time to read the help page, especially the sections named "What topics can I ask about here?" and "What types of questions should I avoid asking?". And more importantly, please read the Stack Overflow question checklist. You might also want to learn about Minimal, Complete, and Verifiable Examples.

    – Clijsters
    Nov 23 '18 at 8:07

















Please take some time to read the help page, especially the sections named "What topics can I ask about here?" and "What types of questions should I avoid asking?". And more importantly, please read the Stack Overflow question checklist. You might also want to learn about Minimal, Complete, and Verifiable Examples.

– Clijsters
Nov 23 '18 at 8:07





Please take some time to read the help page, especially the sections named "What topics can I ask about here?" and "What types of questions should I avoid asking?". And more importantly, please read the Stack Overflow question checklist. You might also want to learn about Minimal, Complete, and Verifiable Examples.

– Clijsters
Nov 23 '18 at 8:07












1 Answer
1






active

oldest

votes


















2














Try the same git filter-branch command with -- --all at the end: that would take care of branches and tags, but also remotes references.



Then check the result of your git log --all



Note also that, with a filter branch, the original refs, if different from the rewritten ones, will be stored in the namespace refs/original/: make sure your git log --all does not list those refs (refs/original): that would still reference your old email.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439187%2fhow-can-i-remove-my-private-email-from-the-git-log-all-format-an-ae-o%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    Try the same git filter-branch command with -- --all at the end: that would take care of branches and tags, but also remotes references.



    Then check the result of your git log --all



    Note also that, with a filter branch, the original refs, if different from the rewritten ones, will be stored in the namespace refs/original/: make sure your git log --all does not list those refs (refs/original): that would still reference your old email.






    share|improve this answer




























      2














      Try the same git filter-branch command with -- --all at the end: that would take care of branches and tags, but also remotes references.



      Then check the result of your git log --all



      Note also that, with a filter branch, the original refs, if different from the rewritten ones, will be stored in the namespace refs/original/: make sure your git log --all does not list those refs (refs/original): that would still reference your old email.






      share|improve this answer


























        2












        2








        2







        Try the same git filter-branch command with -- --all at the end: that would take care of branches and tags, but also remotes references.



        Then check the result of your git log --all



        Note also that, with a filter branch, the original refs, if different from the rewritten ones, will be stored in the namespace refs/original/: make sure your git log --all does not list those refs (refs/original): that would still reference your old email.






        share|improve this answer













        Try the same git filter-branch command with -- --all at the end: that would take care of branches and tags, but also remotes references.



        Then check the result of your git log --all



        Note also that, with a filter branch, the original refs, if different from the rewritten ones, will be stored in the namespace refs/original/: make sure your git log --all does not list those refs (refs/original): that would still reference your old email.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 5:53









        VonCVonC

        839k29426543196




        839k29426543196






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439187%2fhow-can-i-remove-my-private-email-from-the-git-log-all-format-an-ae-o%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Wiesbaden

            Marschland

            Dieringhausen