git-diff

How do I prettily print out a git-diff output?

这一生的挚爱 提交于 2019-12-12 09:33:07
问题 for my upcoming Bachelor thesis, I am required to print out the git-diff output for the appendix of the paper. I really like the output of git diff --color-words , but I have absolutely no idea how to bring this - colored and with line numbers included - to a piece of paper on my Mac. I know there are tools like SourceTree, but even with those I seem not able to make a pretty print out of the single file's diffs. Well, I am pretty sure that I cannot be the only one with this problem, and I

why i cannot checkout another git branch?

淺唱寂寞╮ 提交于 2019-12-12 09:05:49
问题 $ git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/lab_master remotes/origin/master $ git checkout lab_master error: Your local changes to the following files would be overwritten by checkou t: **project.properties** Please, commit your changes or stash them before you can switch branches. Aborting why i just failed to checkout lab_master branch? another question: why i cannot compare current file with the file in another branch? $ git diff project.properties -b lab

Smarter rebase avoiding redundant work?

我怕爱的太早我们不能终老 提交于 2019-12-12 07:43:16
问题 One issue I run into with long rebases is having to resolve redundant conflicts. Say I have a branch with a sequence of commits that keeps modifying a function, and the final commit removes the function entirely. When I do rebase master , Git naively applies each of the commits in turn. That means I need to resolve each of these commits with the tip of master - even though ultimately that work is wasted. What's a good way to deal with this situation? Perhaps I should just generate a single

Equivalent of git diff in JGit

孤人 提交于 2019-12-12 02:57:33
问题 How can I get the result for git diff a.txt b.txt , for files, a.txt and b.txt, that are not part of a repository? I want the output in the format git diff provides. Also, I can't run git commands through Java due to some restrictions. 回答1: The JGit diff code is located in DiffFormatter and its associated classes. If you take a closer look, you'll see that the code isn't meant to diff arbitrary byte streams. It is coupled to a an existing repository with commits, trees, etc. If you don't mind

Git blind spot between staging and remote

时光毁灭记忆、已成空白 提交于 2019-12-12 02:44:16
问题 I'm relatively new to git having come from a VSS / TFS / SVN background. I'm using the git plugin in Visual Studio 2015. So I clone a repository and make some changes to a code file. Then I look at the changes tab (which I presume does a git diff in the background) and I see the changes I made. All fine and dandy. Then I commit the changes to my local repo, after which I make some more changes to a local file, view the changes, and commit again. My problem is that there's now a blind spot

Git diff: ignore lines starting with a word

寵の児 提交于 2019-12-11 11:26:49
问题 As I have learned here, we can tell git diff to ignore lines starting with a * using: git diff -G '^[[:space:]]*[^[:space:]*]' How do I tell git to ignore lines starting with a word, or more (for example: * Generated at ), not just a character? This file shall be ignored, it contains only trivial changes: - * Generated at 2018-11-21 + * Generated at 2018-11-23 This file shall NOT be ignored, it contains NOT only trivial changes: - * Generated at 2018-11-21 + * Generated at 2018-11-23 + * This

git: number of lines *not* changed since specific commit?

对着背影说爱祢 提交于 2019-12-11 10:53:40
问题 There are plenty of answers with great command line fu to find changes (or change statistics), but I'd like to find the opposite: how many lines (per file) have not changed since a particular commit? The closest I could find is this: How to find which files have not changed since commit? but I'd like to know how many lines (ideally: in each file) have survived unchanged, not which files. So, basically: can git diff --stat output unchanged lines in addition to insertions and deletions?

Displaying git diff and git log output on a separate terminal screen

…衆ロ難τιáo~ 提交于 2019-12-11 03:09:14
问题 After setting up new development environment I encountered a strange git behavior that I don't recall seeing in the past. I am used to git diff and git log creating a new screen in the terminal and displaying their output inside (what less does by default, and I'm using it as my pager). I can then quit and go back to my previous terminal state, with the command output gone. Now, however, output is printed right into the same screen as if it was cat (but with a pager). Any ideas how to fix

Git diff: show ONLY changes not matching a pattern

北战南征 提交于 2019-12-11 02:59:56
问题 Is it possible to tell git diff to assume lines staring with some pattern as unchanged? For example, consider the following: $ git diff -U0 diff --git a/file_a.txt b/file_a.txt index 26ed843..4071ff8 100644 --- a/file_a.txt +++ b/file_a.txt @@ -24 +24 @@ - * unimportant foo + * unimportant bar diff --git a/file_b.txt b/file_b.txt index c6d051e..4b3cf22 100644 --- a/file_b.txt +++ b/file_b.txt @@ -24 +24 @@ - * unimportant foo + * unimportant bar @@ -48,0 +49 @@ + this is important @@ -56,0

How to globally apply a textconv filter to all text files?

Deadly 提交于 2019-12-10 22:33:03
问题 I know via gitattributes diff=... one can set files specified by a name pattern to use a textconv specified filter for git-diff et al., but is there any way to have git-diff use a specific diff filter for all files git determines to be text files, no matter their name, but without affecting non-text files? 来源: https://stackoverflow.com/questions/34432841/how-to-globally-apply-a-textconv-filter-to-all-text-files