{"id":24064,"date":"2020-10-12T17:52:39","date_gmt":"2020-10-13T00:52:39","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=24064"},"modified":"2023-12-01T04:01:31","modified_gmt":"2023-12-01T12:01:31","slug":"git-download-a-single-file-from-github","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/","title":{"rendered":"Download a Single File from GitHub: A Guide"},"content":{"rendered":"\n<p>When you <a href=\"https:\/\/careerkarma.com\/blog\/git-clone\/\">clone or pull a Git repository<\/a>, the entire contents of that repository are downloaded by default. Git does not allow you to download part of a repository. Using GitHub, you can download one file from a Git repository.<br><\/p>\n\n\n\n<p>In this guide, we talk about how to download a single file from GitHub. We walk through two examples to help you learn how to download files from the web browser and the command line.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Download a Single File from GitHub<\/h2>\n\n\n\n<p>GitHub lets you download one file from a repository. This is a useful feature because it means you do not have to clone or retrieve an entire repository to download a particular file.<br><\/p>\n\n\n\n<p>You cannot retrieve a single file using the <a href=\"https:\/\/careerkarma.com\/blog\/what-is-git\/\">git command line<\/a>, even if your repository is hosted on GitHub. You need to use the GitHub web interface, or a direct URL to a file.<br><\/p>\n\n\n\n<p>To download an individual file from a repository, first navigate to the file you want to download on the GitHub website. Then, click the \u201cRaw\u201d download button that appears on the top right corner of the file explorer window on your page:<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/phbCcr2zL2KxtvszHjrW5ql1Svy4dDMeszN1kO4x5_orZKsH--rCSYbDsn6FJHA5kKlFzFBeUr5QdhPU8AqI-R8MXlbRTSOF0MxtIxe0yuejGASrrE5SYl7b3Mipc4NAPg\" alt=\"\"\/><\/figure>\n\n\n\n<p>In this example, we are viewing the README.md file in a repository called ck-git. When we click \u201cRaw\u201d, we are directed to a plain-text version of our file.<br><\/p>\n\n\n\n<p>This takes us to the following URL:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>https:\/\/raw.githubusercontent.com\/Career-Karma-Tutorials\/ck-git\/master\/README.md<\/pre><\/div>\n\n\n\n<p>Now that we are viewing a plain-text version of our file, we can save it like we would with any web resource. Press Ctrl-S or Cmd-S for Windows and Mac, respectively, and choose where you want to save the file that you are viewing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Download a Single File Using a URL<\/h2>\n\n\n\n<p>We do not need the web interface to view the raw version of a file. We can manually write the <a href=\"https:\/\/careerkarma.com\/blog\/url-vs-uri\/\">URL of the file<\/a> we want to retrieve.<br><\/p>\n\n\n\n<p>Let\u2019s take another look at the URL that the web interface pointed us to earlier:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>https:\/\/raw.githubusercontent.com\/Career-Karma-Tutorials\/ck-git\/master\/README.md<\/pre><\/div>\n\n\n\n<p>This URL follows a standard format:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>&lt;owner-name&gt;\/&lt;repo-name&gt;\/&lt;branch&gt;\/&lt;file&gt;<\/pre><\/div>\n\n\n\n<p>We can use this format to retrieve any file from our Git archive, such as a HTML file or a markdown file. We could download a file called app.py in a folder called \u201cmain\u201d using this URL:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>https:\/\/raw.githubusercontent.com\/Career-Karma-Tutorials\/ck-git\/master\/main\/app.py<\/pre><\/div>\n\n\n\n<p>This method works on both plain text and binary files. If you need to download an image, for example, you\u2019ll be able to do so using this approach.<br><\/p>\n\n\n\n<p>This approach only works for files that are public. If you want to retrieve a file from a private repository, you\u2019ll need to download it directly from the GitHub web interface. This is because the web interface provides an access token that you need to view a private file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Download a Single File Using Wget<\/h2>\n\n\n\n<p>We can download a single file from the command line using the wget command. This is because we can write the URL for the file we want to retrieve.<br><\/p>\n\n\n\n<p>Like the last approach, you can only download a single file using wget if that file is public.<br><\/p>\n\n\n\n<p>All we have to do to download a single file using wget is write a wget command:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>wget -L https:\/\/raw.githubusercontent.com\/Career-Karma-Tutorials\/ck-git\/master\/main\/app.py<\/pre><\/div>\n\n\n\n<p>This command retrieves the main\/app.py file from our project. The -L flag instructs wget to retrieve only the file that we have specified. We could alternatively use <a href=\"https:\/\/careerkarma.com\/blog\/what-is-curl\/\">cURL<\/a> to retrieve the file we want to download.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>You can download an individual file from a GitHub repository from the web interface, by using a URL, or from the command line.<br><\/p>\n\n\n\n<p>You can only retrieve public files by URL or from the command line. This is because private files are protected by an access token that you can only retrieve by viewing a file from the web interface.<br><\/p>\n\n\n\n<p>Now you have the knowledge you need to download a single file from GitHub like a pro!<\/p>\n","protected":false},"excerpt":{"rendered":"When you clone or pull a Git repository, the entire contents of that repository are downloaded by default. Git does not allow you to download part of a repository. Using GitHub, you can download one file from a Git repository. In this guide, we talk about how to download a single file from GitHub. We&hellip;","protected":false},"author":240,"featured_media":17726,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17286],"tags":[],"class_list":{"0":"post-24064","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-git"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Git","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Download a Single File from GitHub: A Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"On Career Karma, learn how to download a single file from GitHub using the GitHub web interface, a URL, and the wget command.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Download a Single File from GitHub: A Guide\" \/>\n<meta property=\"og:description\" content=\"On Career Karma, learn how to download a single file from GitHub using the GitHub web interface, a URL, and the wget command.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-13T00:52:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:01:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/glenn-carstens-peters-npxXWgQ33ZQ-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"679\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Download a Single File from GitHub: A Guide\",\"datePublished\":\"2020-10-13T00:52:39+00:00\",\"dateModified\":\"2023-12-01T12:01:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/\"},\"wordCount\":638,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/glenn-carstens-peters-npxXWgQ33ZQ-unsplash.jpg\",\"articleSection\":[\"Git\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/\",\"name\":\"Download a Single File from GitHub: A Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/glenn-carstens-peters-npxXWgQ33ZQ-unsplash.jpg\",\"datePublished\":\"2020-10-13T00:52:39+00:00\",\"dateModified\":\"2023-12-01T12:01:31+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"On Career Karma, learn how to download a single file from GitHub using the GitHub web interface, a URL, and the wget command.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/glenn-carstens-peters-npxXWgQ33ZQ-unsplash.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/glenn-carstens-peters-npxXWgQ33ZQ-unsplash.jpg\",\"width\":1020,\"height\":679},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Git\",\"item\":\"https:\/\/careerkarma.com\/blog\/git\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Download a Single File from GitHub: A Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Download a Single File from GitHub: A Guide | Career Karma","description":"On Career Karma, learn how to download a single file from GitHub using the GitHub web interface, a URL, and the wget command.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/","og_locale":"en_US","og_type":"article","og_title":"Download a Single File from GitHub: A Guide","og_description":"On Career Karma, learn how to download a single file from GitHub using the GitHub web interface, a URL, and the wget command.","og_url":"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-10-13T00:52:39+00:00","article_modified_time":"2023-12-01T12:01:31+00:00","og_image":[{"width":1020,"height":679,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/glenn-carstens-peters-npxXWgQ33ZQ-unsplash.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Download a Single File from GitHub: A Guide","datePublished":"2020-10-13T00:52:39+00:00","dateModified":"2023-12-01T12:01:31+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/"},"wordCount":638,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/glenn-carstens-peters-npxXWgQ33ZQ-unsplash.jpg","articleSection":["Git"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/","url":"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/","name":"Download a Single File from GitHub: A Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/glenn-carstens-peters-npxXWgQ33ZQ-unsplash.jpg","datePublished":"2020-10-13T00:52:39+00:00","dateModified":"2023-12-01T12:01:31+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"On Career Karma, learn how to download a single file from GitHub using the GitHub web interface, a URL, and the wget command.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/glenn-carstens-peters-npxXWgQ33ZQ-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/glenn-carstens-peters-npxXWgQ33ZQ-unsplash.jpg","width":1020,"height":679},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/git-download-a-single-file-from-github\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Git","item":"https:\/\/careerkarma.com\/blog\/git\/"},{"@type":"ListItem","position":3,"name":"Download a Single File from GitHub: A Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/24064","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=24064"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/24064\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/17726"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=24064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=24064"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=24064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}