Protecting your commit email on GitHub

If you want to protect your private email in a commit from being exposed, GitHub has provided a way to do that. GitHub supports an no-reply email address that can be specially used as your commit email address.

To use the noreply email, you need to set up both in the GitHub and in your local Git.

GitHub: Setting your commit email address provides a step-by-step instructions how to do that. It’s simple.

GitHub settings

GitHub > Settings > Emails > Check Keep my email addresses private and Block command line pushes that wxpose my email option in the bottom of the page, then it display the noreply email as below:

:ballot_box_with_check: Keep my email addresses private

We’ll remove your public profile email and use xxxxxxx+[username]@users.noreply.github.com when performing web-based Git operations (e.g. edits and merges) and sending email on your behalf. If you want command line Git operations to use your private email you must set your email in Git.

:ballot_box_with_check: Block command line pushes that expose my email

If you push commits that use a private email as your author email we will block the push and warn you about exposing your private email.

Local Git setting

Run below command to configure your commit email with the noreply email:

$ git config --global user.email xxxxxxx+[username]@users.noreply.github.com

Note:

For commits you made prior to changing your commit email address are still associated with your previous email address. That means the commit email in those commit are not protected.

Notes:

In fact, Git does not check whether the email is a valid one or not. Of course you can use a fake one, but noreply email is a better choice, it clearly indicates that.

Resources

GitHub: Setting your commit email address

Adding images to README on GitHub

If you may want to add a few images to README.md to display direct effects of a repository on GitHub, a convenient way is to reference images that are stored in the same repository. Here is a method that allows you to show an image link (although the image itself does not display directly), and this does not affect README.md display in a local repository.

Below is an example to reference screenshots/demo.png whose path is relative to the REAMDE.md file in the repository:

![Image alt text](screenshots/demo.png?raw=true)

Or with a title:

![Image alt text](screenshots/demo.png?raw=true "Image title")

Then the image shows as below in HTML source code on the repository’s page. Actually it still shows as an image link rather than directly displaying the image, but it is able to direct to a page that displays the image.

<img src="/[username]/[repo-name]/raw/master/screenshots/demo.png?raw=true" alt="GCMovie list table" style="max-width:100%;" >

The directed page URL will redirect to a link like below in the browser:

https://raw.githubusercontent.com/[usename]/[repo-name]/master/screenshots/demo.png

Using a relative link to point a file in the repository make it works both in the GitHub and in a local repository. You can put a link in the README.md to point a file:

[Contribution guidelines for this project](docs/CONTRIBUTING.md)

See Relative links and image paths in README files for more details.

Resources