1

Following compare local git branch with remote branch?, I'm trying to show the difference with a remote branch, but it doesn't seem to work as expected. Here is my git status:

Kurts-MacBook-Pro:dashboard kurtpeek$ git status
On branch session-deletion
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   urls.py

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    ../../.env
    templates/sessions/_delete.html

no changes added to commit (use "git add" and/or "git commit -a")

My git branch --all contains a remotes/origin/staging:

Kurts-MacBook-Pro:dashboard kurtpeek$ git branch --all | grep remotes/origin/staging
  remotes/origin/staging

A git diff urls.py shows a difference which I'm sure also exists with the staging branch:

Kurts-MacBook-Pro:dashboard kurtpeek$ git diff urls.py
diff --git a/lucy-web/dashboard/urls.py b/lucy-web/dashboard/urls.py
index bcbb6af2..15d75b84 100644
--- a/lucy-web/dashboard/urls.py
+++ b/lucy-web/dashboard/urls.py
@@ -204,6 +204,11 @@ urlpatterns = [
         views.SessionUpdate.as_view(),
         name='session'
     ),
+    url(
+        r'^sessions/(?P<pk>[0-9]+)/delete$',
+        views.SessionDelete.as_view(),
+        name='session-delete'
+    ),
     url(
         r'^sessions/(?P<pk>[0-9]+)/schedule/(?P<target>[a-z]+)$',
         views.SessionSchedule.as_view(),

I've tried various calls to git diff to compare the remote staging branch with my local session-deletion branch, but none of them show any difference:

Kurts-MacBook-Pro:dashboard kurtpeek$ git diff session-deletion remotes/origin/staging -- urls.py
Kurts-MacBook-Pro:dashboard kurtpeek$ git diff remotes/origin/staging.. -- urls.py
Kurts-MacBook-Pro:dashboard kurtpeek$ git diff remotes/origin/staging... -- urls.py
deletion..remotes/origin/staging -- urls.py
Kurts-MacBook-Pro:dashboard kurtpeek$ 

Any idea what the issue is here?

Kurt Peek
  • 52,165
  • 91
  • 301
  • 526

1 Answers1

2

Using diff with $ref.. implies $ref..HEAD, so it's not comparing the local state of your working directory, instead comparing two "real" references.

To compare a ref with what's in your working directory, use diff $ref.

Man page excerpt:

   git diff [--options] <commit> [--] [<path>...]
       This form is to view the changes you have in your working tree relative to the
       named <commit>. You can use HEAD to compare it with the latest commit, or
       a branch name to compare with the tip of a different branch.

   git diff [--options] <commit> <commit> [--] [<path>...]
       This is to view the changes between two arbitrary <commit>.

   git diff [--options] <commit>..<commit> [--] [<path>...]
       This is synonymous to the previous form. If <commit> on one side is omitted,
       it will have the same effect as using HEAD instead.
amphetamachine
  • 27,620
  • 12
  • 60
  • 72