ignore certain files(types) from git diff

Sometimes it’s silly when reviewing the code change from git diff command which is a simple way to see the differences between the codes from the previous and the updated and the commit contains a large css file. Actually I use less for generating css, so I don’t really need to open up and see the css file. Anyways, you can ignore any file you want from git diff. Here’s how.

You can create a .gitattributes file in the root of the repo. Inside that file, you can now exclude certain files/types from the git diff command just like the way of excluding files from .gitignore:

path/to/file.binary -diff
path/to/files/*.css -diff

List all the files in a git repository

If you want to list all files for a specific branch, e.g. master:

$ git ls-tree -r master --name-only

-d Show only the named tree entry itself, not its children.
-r Recurse into sub-trees.

You can specify HEAD instead of master to get the list for any other branch you might be in.

If you want to get a list of all files that ever existed:

$ git log --pretty=format: --name-only --diff-filter=A | sort -

Download a file from page via HTTPS(SSL)

string _path = Server.MapPath(ConfigurationSettings.AppSettings["path"]);

if (File.Exists(_path))
    string data = File.ReadAllText(_path);

    byte[] byteArr = Encoding.UTF8.GetBytes(data);
    MemoryStream stream = new MemoryStream(byteArr);

    // downloading file via HTTPS(SSL) will not work w/o clearing resposne.
                       "attachment; filename=" + Path.GetFileName(_path) + "\"");
    Response.AddHeader("Content-Length", byteArr.Length.ToString());
    Response.ContentType = "application/octet-stream";