git-diff

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

帅比萌擦擦* 提交于 2019-12-04 02:11:03
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 master upstream/master as advised here , I get this: fatal: ambiguous argument 'upstream': unknown

How can I make `git diff` as fine-grained as StackExchange diff?

北慕城南 提交于 2019-12-03 21:44:24
Is there a diff tool which can highlight single character edits as such, and not just show the old and new version of the whole line (i.e. the kind of diff StackExchange shows you for edits to a post)? I'd prefer one I could use on the Linux command line as diff in git . You can try, from git diff : git diff --color-word=. Which is equivalent to --word-diff=color plus (if a regex was specified) --word-diff-regex=<regex> . That would transform this git diff : into this one: Images are from the section " Produce more useful diffs " of the article " 30 Git CLI options you should know about "

How to make git log show file paths relative to current directory?

三世轮回 提交于 2019-12-03 16:43:07
The current Git-based project that I am working on, I am generally always in a sub-directory. Below is the output when I run the command git log --name-only from a sub-directory of the root of the repository. commit 678bd5ba6fc5474c4c61406768bf6cba5937c5d1 Author: thegreendroid Date: Mon Mar 27 09:36:24 2017 +1300 Commit message child_dir1_from_root/file1 | 184 +-- child_dir2_from_root/file2 | 2 +- How do I instead get git log to output something like below instead? This makes diffing the files listed really easy, by just copying the file path and running git diff HEAD~ {copied_file_path}

Github/compare: How to diff two different files (different file names, both in HEAD)?

拜拜、爱过 提交于 2019-12-03 14:38:44
问题 Can I use the github /compare to display the difference between two different source files in HEAD? Here is how I do it on the command line with git diff : git diff HEAD:docs/tutorial/01-boxed-function-pointers.cpp HEAD:docs/tutorial/02-raw-actors.cpp My best guess at the github syntax is the following. But it doesn't work: https://github.com/RossBencina/Fractorp/compare/HEAD:docs/tutorial/01-boxed-function-pointers.cpp...HEAD:docs/tutorial/02-raw-actors.cpp I specifically want an on-line

git: Why doesn't git diff show any differences?

匆匆过客 提交于 2019-12-03 14:25:18
问题 If I run 'git status' on my repo it gives: # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: myfile However, if I do a 'git diff myfile' it shows no differences. Is this because I have made a change and removed it so it is back to the original? Should I run 'git checkout myfile' to clear it? 回答1: Your file is already staged to be committed. You can show it's diff using the --cached option of git. git diff --cached myfile To unstage it,

Differences between the staged and unstaged versions of the same file, using difftool [duplicate]

依然范特西╮ 提交于 2019-12-03 11:45:56
This question already has answers here : Show both staged & working tree in git diff? (3 answers) Is there a way of viewing the differences between the staged and unstaged versions of the same file? For example: Changes to be committed: modified: conf/application.conf Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: conf/application.conf This happens when I stage a change and then I modify the file again, without staging it. EDIT The git status -vv command is not good

Ignore any blank space or line break in git-diff

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 10:05:52
I have the same file rendered in two different ways and want to compare it using git diff , taking care of ignoring every white-space, tab, line-break, carriage-return , or anything that is not strictly the source code of my files. I'm actually trying this: git diff --no-index --color --ignore-all-space <file1> <file2> but when some html tags are collapsed all on one line (instead of one per line and tabulated) git-diff detect is as a difference (while for me it is not). <html><head><title>TITLE</title><meta ...... is different from <html> <head> <title>TITLE</title> <meta ...... What option

git diff: what is the difference between --cached and --staged

蹲街弑〆低调 提交于 2019-12-03 09:34:39
To compare the staged with the last commit: git diff --cached git diff --staged Both commands generate the same results, right? The documentation for git diff says " --staged is a synonym of - -cached ", so yes. From the docs - --staged is a synonym of --cached git-scm.com/docs/git-diff (see bolded text): git diff [<options>] --cached [<commit>] [--] [<path>…​] This form is to view the changes you staged for the next commit relative to the named <commit> . Typically you would want comparison with the latest commit, so if you do not give , it defaults to HEAD. If HEAD does not exist (e.g.

why `git diff` reports no file change after `git add`

巧了我就是萌 提交于 2019-12-03 08:43:18
问题 Why is that git diff thinks there are no changes ..even if git status reports them as modified ? $ git status On branch master Your branch is ahead of 'origin/master' by 2 commits. (use "git push" to publish your local commits) Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: file-added modified: file-with-changes << it knows there are changes but in order to see the difference, I need to explicitly add the last reversion hash.. $ git diff (nothing) $ git diff

Git diff: is it possible to show ONLY changed lines

扶醉桌前 提交于 2019-12-03 08:40:06
问题 I'm trying to get only new version of lines which have changed and not all the other info which git diff shows. For: git diff HEAD --no-ext-diff --unified=0 --exit-code -a --no-prefix It shows: diff --git file1 file2 index d9db605..a884b50 100644 --- file1 +++ file2 @@ -16 +16 @@ bla bla bla -old text +new text what I want to see is only: new text Is it possible? 回答1: Only added lines does not make sense in all cases. If you replaced some block of text and you happend to include a single line