git-diff

git diff --stat exclude certain files

强颜欢笑 提交于 2019-11-30 11:54:22
Trying to adapt the answers from Want to exclude file from "git diff" for the --stat flag and failing - the accepted answer (create a driver) seems unix only (redirect to /bin/true, whatever this means) plus it creates a driver and assigns it to the file kind of permanently, while I am looking for a switch to temporarily disable the diff for a file (or rather some files). The scripting solution : git diff `git status -s |grep -v ^\ D |grep -v file/to/exclude.txt |cut -b4-` actually calls git status and edits its output - while what I want is to instruct git diff itself to ignore some files

is it possible to add a comment to a diff file (unified)?

前提是你 提交于 2019-11-30 08:08:14
I wonder if it's possible to add a certain amount of unparsed content to a diff file (unified) that is ignored as a comment. One good use of this would be having git diffs augmented with important information such as from which branch is that diff from (especially when using the --full-index option, which merely displays the blob references). The unified diff starts with two line header: --- from-file from-file-modification-time +++ to-file to-file-modification-time Anything before this header is ignored, so you can add any comment here, for example: This may be some useful description of this

git: list of all changed files including those in submodules

旧时模样 提交于 2019-11-30 06:23:29
问题 I would like to get a list of all files, which have changed betweet two commits including those in submodules. I know I can do this: git diff --name-only --diff-filter=ACMR ${revision} HEAD It returns a list of files, including the submodule-path, but not the files within. Example: I've updated a submodule. I commited the super-project. Now I want to get a list of all files which have been modified. Do you know a way to get this done? 回答1: Update 2017: as I mentioned in "see diff of commit on

How to download a single commit-diff from GitHub?

守給你的承諾、 提交于 2019-11-30 06:12:57
问题 I would like to get a single commit (let's call it ${SHA} ) from GitHub via the web-interface. For example, something like: $ git clone http://github.com/foo/bar $ cd bar $ git format-patch -o .. ${SHA}~1..${SHA} $ cd .. $ rm -rf bar ...but without having to clone the entire repository (the repo in question is large). Obviously GitHub can display the diff of a given commit via the web interface, but how I can extract that into a (unified) diff-file (ideally, with the commit-message intact)?

GIT - How to list only newly added files between two branches

笑着哭i 提交于 2019-11-30 01:41:23
how can I list newly created(added) files between two branches? I can list all files that have been changed with: git diff --color --name-only branch1..branch2 But that also contains files, that just changed their content, not necessarily new files. Is there some git command for this, or do I have to checkout each branch and compare the files, e.g. with bash? Thanks. Filip michas Just replace --name-only with --name-status . This way git will show if the file is added, deleted or just modified. If you are only interested in the new (=added) files you can simply grep for ^A : git diff --name

How can I get content of a file from git index?

。_饼干妹妹 提交于 2019-11-30 01:27:18
I have a file which has been already added to my local repository. I've modified it in the working tree, so git status shows me the file as modified. I would like to know what is the file content kept in the index before I stage the file. I can think of two ways of doing that: revert a patch generated by git diff , and apply it on the file in the working tree use git checkout-index , point to a temporary file and read the content from there Is there an easier way? grawity Use the : prefix to access objects in the current index (staged but not yet commited). git show :file See the gitrevisions

How to make git diff show the same result as github's pull request diff?

橙三吉。 提交于 2019-11-30 01:11:33
问题 After branches are merged, and github no longer show difference when i try to make a pull request, but git diff will still show differences. For example I have branch D, created hotfix on branch H, merged H to D, then created more stuff on D. Now git hub pull reuqest from H to D shows no difference but git diff H D show differences. What I am trying to do is to create a commandline tool to see which old branches (there can be a lot) don't have code differences to develop. right now I have to

Examples of different results produced by the standard (Myers), minimal, patience and histogram diff algorithms

我的未来我决定 提交于 2019-11-29 22:50:27
Git offers these 4 diff algorithms, but without any further information what are their differences. What are the advantages of each of this algorithms? Is there some comparison of various cases where the algorithms perform differently? jelle foks I think there are multiple algorithms supported because none of the algorithms are clearly the best choice in all cases. The differences are in readability of the patch output and processing time needed to generate the patch. Summarizing, this is what I understand the differences are: Myers: The original algorithm as implemented in xdiff ( http://www

What is the reason for the /a /b prefixes of git diff

别等时光非礼了梦想. 提交于 2019-11-29 22:47:34
I've been using git for some years now and always wondered why git diff prefixes the names of modified files with a/ and b/. I expected to eventually stumble upon a use-case where it is useful, but until now it was always annoying and never helpful. What is it good for? Why is this enabled by default? In which situations is it useful? As mentioned in the diff man page , a/ et b/ represent the prefix to differentiate source and destination. Actually, you have the options: --no-prefix Do not show any source or destination prefix. --src-prefix=<prefix> Show the given source prefix instead of "a/"

Git: remove leading plus/minus from lines in diff

折月煮酒 提交于 2019-11-29 21:24:55
My question is rather simple, though I have had no luck finding an answer. I'd like to remove the leading plus/minus symbols from each line in git diff . Before you ask why I wish to do this, allow me to outline my reasons: Lines that are exactly 80 chars will overflow by a single character, which just looks plain awkward The coloring is enough for me to distinguish between additions/deletions I'd prefer to keep my Terminal's window width at 80 chars (as opposed to an arbitrary 81 chars) to maintain consistency with everything else I do in my Terminal (outside of git ) Is there some config