git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git diff

From
Mike Rappazzo <rappazzo@gmail.com>
Date
Oct 12, 2016, 11:06 UTC
Message-ID
<CANoM8SUtrV8CD8M=4CUB8xr9gQj_hKzGOdjQZHuz4+36y_UfJw@mail.gmail.com>
In-Reply-To
<1066408917.43087.1476269456819.JavaMail.open-xchange@app06.ox.hosteurope.de>
On Wed, Oct 12, 2016 at 6:50 AM,  <webmaster@peter-speer.de> wrote:
Show 12 quoted lines
> Hi.
>
> I created a new branch named hotfix from master.
> I switched to the branch, changed 1 file.
>
> Now I want to see the diff from the both using
>
> git diff hotfix master
>
> I do not see any output (difference).
> When I do a git status I see my file with status mofified, not staged for
> commit.

Since you just created the branch, and did not add any content, there is no difference to see. A branch is just a pointer to a commit. You now have two pointers pointing at the same commit.

If you want to see the difference between your changes and the master branch, you can omit the first reference:

    git diff master

When you start adding commits to your hotfix branch, you will be able to see the diff between that and master with the command that you gave. However, your arguments may be in the reverse order than what you expect. You want to specify master first because that is the mainline branch (I presume).

When you have several commits on your hotfix branch, you can refer to older commits to diff against. There are several ways to refer back, but the simplest is to use a tilde '~' followed by a number to count back. For example 'hotfix~1' refers to the parent commit on the hotfix branch. There is a lot in the documentation[1], so take a look there for more info.

Good luck. _Mike

[1] https://git-scm.com/doc
Show 5 quoted lines
> Also, I can see that I am working with the correct branch, hotfix
>
> What am I doing wrong?
>
> -fuz
On Wed, Oct 12, 2016 at 6:50 AM,  <webmaster@peter-speer.de> wrote:
Show 17 quoted lines
> Hi.
>
> I created a new branch named hotfix from master.
> I switched to the branch, changed 1 file.
>
> Now I want to see the diff from the both using
>
> git diff hotfix master
>
> I do not see any output (difference).
> When I do a git status I see my file with status mofified, not staged for
> commit.
> Also, I can see that I am working with the correct branch, hotfix
>
> What am I doing wrong?
>
> -fuz
Previous: webmaster@peter-speer.deNext: webmaster@peter-speer.de
Message 2 of 3 in “git diff”
  1. webmaster@peter-speer.deOct 12, 2016
  2. Mike RappazzoOct 12, 2016
  3. webmaster@peter-speer.deOct 12, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.