11

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!

Ravexina
  • 54,268
  • 25
  • 157
  • 179
J.Doe
  • 171
  • 1
  • 2
  • 8

3 Answers3

12

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
    
Sohail Si
  • 113
  • 7
George Udosen
  • 35,970
  • 13
  • 99
  • 121
5

I suggest the following command :

git archive [email protected]:foo/bar.git HEAD |  tar xvf - path/to
ejammes
  • 51
  • 1
  • 2
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 [email protected]:foo/bar.git --prefix=path/to/ HEAD:path/to/ | tar xvf -

Ravexina
  • 54,268
  • 25
  • 157
  • 179
  • ;) Just for note: `wget` is a download manager, just like `curl`, `aria2`, `axel`, `firefox` download manager, or anything else :) – Ravexina May 06 '17 at 18:06
  • What are the difference between those download manager? – J.Doe May 06 '17 at 18:08
  • Options and capabilities; With the accepted instruction, you are downloading the same file as I said with a different tool ... – Ravexina May 06 '17 at 18:09