How to retrive a single file from github using git [closed]

You can get that file using wget:

  1. Create a directory:

     mkdir mypycode
    
  2. Change into that directory:

     cd mypycode
    
  3. Identify the raw URL

  • Navigate to your file on github (or your git host)
  • Click on the Raw tab.
  1. Use wget to download it:

     wget https://raw.githubusercontent.com/tensorflow/tensorflow/r1.1/tensorflow/examples/tutorials/mnist/mnist_softmax.py
    

I suggest the following command :

git archive [email protected]:foo/bar.git HEAD |  tar xvf - path/to

You can't clone a single file using git.

Git is a distributed version control system, the Idea behind its clone functionality is to have a complete copy of project and all versions of files related to that project.

Either download your file directly from here or clone the whole project using:

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

Also from here:

If there is web interface deployed (like gitweb, cgit, Gitorious, ginatra), you can use it to download single file ('raw' or 'plain' view).

If other side enabled it, you can use git archive's '--remote=' option (and possibly limit it to a directory given file resides in), for example:

$ git archive [email protected]:foo/bar.git --prefix=path/to/ HEAD:path/to/ | tar xvf -