Samuel Edwin Ward
Samuel Edwin Ward

Reputation: 6675

Can I compare an untracked file with a remote repository?

I have a file, which is not in a git repository, which was a copy of a file that's now in a repository on github. Can git show me the differences between these files?

I tried something like git diff master@https://github.com/.../....git -- myfile but I don't think that's remotely right, and I can't seem to figure out how to reference such a remote file from the man pages.

I'd rather avoid checking out the whole remote repository or downloading the raw file just to do this.

Upvotes: 1

Views: 72

Answers (1)

Schwern
Schwern

Reputation: 164919

I don't think it's possible. Git's network protocol is mostly limited to moving objects around by design. However it is possible to make cloning the repository faster.

You can make the clone a little faster by doing a shallow clone, just the files without history, with git clone --depth 1 <url>.


Alternatively, you can take advantage of a Github feature and diff with the raw copy of the file. Use curl -s to download the file and pipe it to diff - yourfile.

curl -s https://raw.githubusercontent.com/evalEmpire/piledriver/master/.travis.yml | diff -u - .travis.yml 

Upvotes: 4

Related Questions