Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignoring specific files, file types or folders in a pull request diff

We frequently use the Files Changed tab on a pull request to peer review the work we have done on a branch, unfortunately a major part of our development process is regenerating Flex services so when viewing the files changed 99% of the changes are irrelevant. This makes it very easy to miss important changes that should be reviewed.

We know the folder that these regenerated services live in, and we could commit all the regen changes in one commit if that would help.

Does anyone have any suggestions how we can improve this? Ideally we would exclude a folder from the pull request diff.

like image 217
BombTodley Avatar asked Nov 21 '13 12:11

BombTodley


People also ask

How do I only put certain files in a pull request?

Pull requests merge branches. So if you want to isolate some things for a pull request, best is to put those changes in a separate branch. Advantage is that you can change the pull request by pushing new changes to that branch (even push -f if you need to change already pushed commits).

How do I ignore a folder in git?

If you want to maintain a folder and not the files inside it, just put a ". gitignore" file in the folder with "*" as the content. This file will make Git ignore all content from the repository.


1 Answers

Github supports this now with a .gitattributes file.

  1. Create a .gitattributes file in the root of the repository.

  2. Use the linguist-generated attribute to mark or unmark paths that you would like to be ignored for the repository's language statistics and hidden by default in diffs.

For example, to mark search/index.json as a generated file, add this line to .gitattributes:

search/index.json linguist-generated=true 

Reference: https://help.github.com/en/github/administering-a-repository/customizing-how-changed-files-appear-on-github

like image 111
prograhammer Avatar answered Oct 18 '22 16:10

prograhammer