3

First I did git status on my newly cloned repo

$ git status
On branch Test
nothing to commit, working directory clean

Now I copies a Test project from another Directory

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

        Test/

no thing added to commit but untracked files present (use "git add" to track)

Following are the files

$ ls Test -a
./  ../  .classpath  .gitignore  .project  Test.class  Test.java

But git diff gives below result

$ git diff

Basically, nothing. But if I stage it and do the git diff -cached it shows as bellow

$ git diff --cached
diff --git a/Test/.classpath b/Test/.classpath
new file mode 100644
index 0000000..233be1d
--- /dev/null
+++ b/Test/.classpath
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path=""/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="output" path=""/>
+</classpath>
diff --git a/Test/.gitignore b/Test/.gitignore
new file mode 100644
index 0000000..a9819ad
--- /dev/null
+++ b/Test/.gitignore
@@ -0,0 +1 @@
+/Test.class
diff --git a/Test/.project b/Test/.project
new file mode 100644
index 0000000..b6bd205
....

How can I see above changes without staging it ( i.e. while copied folder is unstaged).

Please explain how git works here. Is it ever possible to see copied folder/file changes without first commit ?

Siddharth
  • 213
  • 5
  • 14
  • 1
    Would `git add --intent-to-add Test ; git diff` (or `git add -N`) work for you? – knittl Oct 30 '16 at 07:02
  • 1
    Possible duplicate of [Can I use git diff on untracked files?](http://stackoverflow.com/questions/855767/can-i-use-git-diff-on-untracked-files) – 1615903 Oct 31 '16 at 05:14
  • @knitti That works, but I was trying to find a way to do that without doing that every time I add a new file. because I do that a lot. Just a single small command. I don't know if that is only me or there are other who also don't want to go through all the trouble for new files. – Siddharth Oct 31 '16 at 16:10

1 Answers1

2

How about git status --porcelain | grep -e '^??' | sed -e 's/^?? //g' | xargs less?

You can see all untracked files by less.

kaitoy
  • 1,545
  • 9
  • 16