git-diff

Is it possible to 'git diff' 2 strings?

ⅰ亾dé卋堺 提交于 2019-12-10 21:42:51
问题 I have 2 strings and I want the git diff between them. I could create file1 and add string1 as its contents. Then I could create file2 and add string2 as its contents. Then I could git diff file1 and file2. However, given that I have the strings as strings (and not as file contents) can I avoid these long-winded steps? Is there an easier way? Something like: git diff "my first string" "my second string" # obviously does not work 回答1: If you insist on the git way, git diff $(echo "my first

The output of git diff is not handled correctly in powershell

亡梦爱人 提交于 2019-12-10 19:05:00
问题 I have read several QAs to this problem, but none provided an answer. There is a workaround, which I state here again, but I want to understand and solve the problem. Problem The issue is that executing the command git diff reva revb | Out-File mypatch.patch in powershell produces "garbage characters" in place of e.g. German umlauts (├ñ instead of ä). Investigation When I perform $Env:LESSCHARSET="utf8" as suggested in some QAs, I do get correct output in the terminal, but once it is

Git - get a list of files that are identical between two revisions

徘徊边缘 提交于 2019-12-10 17:14:40
问题 like the inverse of git diff --name-only 回答1: You can do this by looking at unique values from ls-tree and diff with the --name-only options (done in one line so it's easier to search and use from history later): cat <(git ls-tree --name-only -r HEAD) <(git diff --name-only HEAD^ HEAD) | sort | uniq -u In the example, the 2 revisions are HEAD and HEAD^. This produces no side effect output files. 回答2: You could do this using the comm command and some shell commands: git ls-files >files.txt git

Is there something similar to diff --show-c-function in git-diff?

烂漫一生 提交于 2019-12-10 13:18:02
问题 I've been working on a file in my git repository. If I have a copy of the original git version of the file, I can run diff --show-c-function to get a comparison of the 2, files, where (in theory) it shows the whole of any function which has been changed. This is really useful for working out what I did specifically to a file, in working out the comment I'd need. However in git-diff, this option is missing. Is there some way to make this work (or am I stuck having to get 2 copies of the file

Need to get all file differences (added, modified, renamed) between two Git commits

喜夏-厌秋 提交于 2019-12-10 11:35:38
问题 I'm trying to export all files with differences between two commits, those differences being: New files (Added) Modified files Renamed files If possible, information on any deleted files Detecting renames may be a tough one as I will be doing the exporting on a Windows 7 environment and hence somefile.php is the same as SomeFile.php ; but I will be uploading them to a *nix environment, which does treat those files as being different, so they are needed to be recognized and exported if

Git show whole file changes

假如想象 提交于 2019-12-10 10:14:36
问题 Is there a way to get the git show command to show the whole contents of a file when viewing a commit? For example: if it currently show something like foo.cpp +++ int main() { +++ std::cout << "HELLO" << std::endl; +++ } I would want the output to say: foo.cpp #include <stdio> //assuming this was from an earlier commit +++ int main() { +++ std::cout << "HELLO" << std::endl; +++ } Is there a simple way to do this? 回答1: This is kind of a hack, but git show (like git diff ) has the -U option

gitpython and git diff

吃可爱长大的小学妹 提交于 2019-12-10 02:13:55
问题 I am looking to get only the diff of a file changed from a git repo. Right now, I am using gitpython to actually get the commit objects and the files of git changes, but I want to do a dependency analysis on only the parts of the file changed. Is there any way to get the git diff from git python? Or am I going to have to compare each of the files by reading line by line? 回答1: You can use GitPython with the git command "diff", just need to use the "tree" object of each commit or the branch for

How to use different merge and diff tool in git?

对着背影说爱祢 提交于 2019-12-09 23:45:19
问题 I prefer to use meld as the diff tool. However it doesn't have an option to quickly solve all simple conflicts so in case of merging I'd like to use kdiff3 I've set merge.tool to kdiff3 and diff.guitool to meld but git difftool still always run kdiff3 [merge] tool = kdiff3 conflictstyle = diff3 [diff] guitool = meld renames = copies mnemonicPrefix = true [difftool] prompt = false How to make git difftool run meld ? 回答1: diff.guitool only applies if you use the --gui flag. Setting diff.tool

How can I compare my local forked repository with changes that may have been made to the original?

风流意气都作罢 提交于 2019-12-09 14:43:59
问题 I want to compare the local clone of a repository I have forked with the original/upstream repository to see if further commits have been made requiring me to pull/merge. I'd like to do this from the command line. I added the original repository to my list of remotes with this command: git remote add upstream <original repo URL> This is outlined in Github's own page on the topic of forking a branch. However, when I run git diff upstream or git diff upstream/master as advised here or git diff

How do I use git diff -G?

别说谁变了你拦得住时间么 提交于 2019-12-09 13:35:02
问题 I'm writing a little test suite that runs the tool to be tested over a bunch of input files. For each input file, a corresponding output file is being created by the tool (both are in XML). Input and output files are checked in on a Git repo. The output files carry the time when the tool was compiled, so the output files are surely modified after they were re-created by the tool being tested. To have a quick glimpse if the output has changed (when I modified the sources of the tool), I'd like