Ubuntu: How to retrive a single file from github using git



Question:

I would like to learn more about this code, but I am not able to import it into my computer. How could I clone this file with git? The file is simply:

https://github.com/tensorflow/tensorflow/blob/r1.1/tensorflow/examples/tutorials/mnist/mnist_softmax.py.   

Thanks!


Solution:1

You can get that file using wget:

  1. Create a directory:

    mkdir mypycode  
  2. Change into that directory:

    cd mypycode  
  3. Use wget to download it:

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


Solution:2

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 --remote=git@github.com:foo/bar.git --prefix=path/to/ HEAD:path/to/ | tar xvf -


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »