Search code examples
gitgulp

git - get remote file content


Is there a way in git to get the content of a specific file on the remote repo?

I would like, using gulp, to get the remote package.json version and manipulate the local package.json to match.

The goal is to prevent re-occuring git conflicts on the package.json version field.


Solution

  • If you have fetched data from remote (all you need is to git fetch, it will not touch your current working tree) you can then use:

    git show <ref>:<path>
    

    So in your example you can view content of the file via

    git show origin/master:package.json