0

I have read a number of threads here on this topic but I am not able to figure out why this is not working as expected.

Here are the steps I took:

I installed and downloaded a certain library from the online git repository using

Step 1

git clone https://github.com/deepchem/deepchem.git 

The library was installed under /home/username/deepchem. This is a local git repository and does have the .git folder. I modified some files in this folder.

Step 2

Next, I created an online fork.

Following the instructions here, I did:

git remote add upstream https://github.com/onlineusername/deepchem

git fetch upstream

git diff master upstream/master

I was hoping to diff between the local repository in “/home/username/deepchem” that I had fetched and modified in Step 1. However when I did the git diff in Step2, it didn’t show the changes that I know are present between the online fork and the current local repository (/home/username/deepchem). I think it’s mainly showing the diff between my online fork and the current master.

How do I get a diff between the online fork and my current local repository stored in /home/username/deepchem?

Thanks a lot!

Tim Miller
  • 566
  • 5
  • 17
alpha_989
  • 4,882
  • 2
  • 37
  • 48
  • 1
    Did you actually commit your local changes? What happens if you run `git status` and `git diff`? – Useless Jun 28 '17 at 17:14
  • 1
    You can try `git diff upstream/master` which will diff your current checked out branch (including changes, however not files not yet added) to upstream/master – JohanL Jun 28 '17 at 17:15
  • @Useless, You maybe right.. didnt know I had to commit these changes. When I did git status the first time, it showed.. "modified: filename1.... modified: filename2... etc". Also it said "no changes added to commit (use "git add" and/or "git commit -a"). – alpha_989 Jun 28 '17 at 18:23
  • So I did "git add ." while being in the directory containing the .git directory. Now it reads "new file: AUTHORS new file: examples/tensorgraph/test_mnist.py... etc etc". – alpha_989 Jun 28 '17 at 18:23
  • However, the changes between my online fork and my local directory which is present in the file examples/tensorgraph/test_mnist.py, still doesnt show up when I do "git diff master upstream/master".. – alpha_989 Jun 28 '17 at 18:23
  • Is there something else that I am missing? – alpha_989 Jun 28 '17 at 18:23
  • also now "git diff" basically returns null output – alpha_989 Jun 28 '17 at 18:26
  • @JohanL, i am trying to do a diff between my local repo and my online fork.. I dont want to necessary update my online fork with these changes yet.. – alpha_989 Jun 28 '17 at 18:27
  • 2
    When you have done `git add` but not `git commit` your changes are in the so called staging area. Then they will not show in a normal diff. You should be able to diff your local changes directly (without adding them) to the remote. If you do `git reset`(to get your changes out of the staging area, the changes won't disappear), followed by `git diff upstream/master´, what do you get then? – JohanL Jun 28 '17 at 18:30
  • Wow.. Interesting.. thank you @JohanL. This worked great.. i am now able to see the changes with "git diff upstream/master" – alpha_989 Jun 28 '17 at 18:34
  • 1
    It seems reading threads on here isn't a good system for learning git - try reading the git book or one of the many online tutorials. – Useless Jun 29 '17 at 08:47

0 Answers0