{"id":21896274,"url":"https://github.com/sabicalija/git-lfs-intro","last_synced_at":"2025-10-23T15:10:43.364Z","repository":{"id":64914578,"uuid":"103855107","full_name":"sabicalija/git-lfs-intro","owner":"sabicalija","description":"git-lfs introduction","archived":false,"fork":false,"pushed_at":"2017-09-19T13:04:58.000Z","size":28,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-28T22:35:22.623Z","etag":null,"topics":["git","git-lfs"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sabicalija.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-17T19:16:58.000Z","updated_at":"2023-07-20T12:03:59.000Z","dependencies_parsed_at":"2022-12-18T12:00:51.106Z","dependency_job_id":null,"html_url":"https://github.com/sabicalija/git-lfs-intro","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabicalija%2Fgit-lfs-intro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabicalija%2Fgit-lfs-intro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabicalija%2Fgit-lfs-intro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabicalija%2Fgit-lfs-intro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sabicalija","download_url":"https://codeload.github.com/sabicalija/git-lfs-intro/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249110686,"owners_count":21214379,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","git-lfs"],"created_at":"2024-11-28T13:43:39.654Z","updated_at":"2025-10-23T15:10:38.305Z","avatar_url":"https://github.com/sabicalija.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"= git-lfs tutorial\nAlija Sabic, link:mailto:sabic.alija@gmail.com?subject=GitHub:\u0026#160;git-lfs-intro[sabic.alija@gmail.com]\n\n:icons: font\n:icon-set: font\n\n// Set new URI for reference to FontAwesome CSS\n:iconfont-cdn: //maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.mi$\n\n:caution-caption: ☠\n:important-caption: ❗\n:note-caption: 🛈\n:tip-caption: 💡\n:warning-caption: ⚠\n\n\n:toc: left\n:toc2:\n:docinfo2:\n// article, book or manpage\n:doctype: article\n:source-highlighter: prettify\n\n\n== Setup git repository with *git-lfs*\n\nThis repository was setup using following commands:\n\n. Create a directory\n+\n.Create directory\n[subs=\"verbatim,macros\"]\n----\npass:q[~$ *mkdir* git-lfs-intro]\npass:q[~$ *cd* git-lfs-intro]\n----\n\n. Initialize git and git-lfs\n+\n[CAUTION]\n=====\n`*git lfs install* --local --skip-smudge` (explained below) adds configuration locally (folder).\nHowever, the local configuration file (`.git/config`) can't be tracked and hence, uploaded to a remote repository.\n\nUse `*git lfs install* --skip-smudge` to prevent LFS from downloading or cloning files (globally) unless explicitly specified.\n\n\n[WARNING]\n====\n`--skip-smudge` adds following entries to the global git config at `~/.gitconfig`:\n\n`.git/config` {nbsp} {nbsp} {nbsp} filter.lfs.required=true +\n`.git/config` {nbsp} {nbsp} {nbsp} filter.lfs.clean=git-lfs clean -- %f +\n`.git/config` {nbsp} {nbsp} {nbsp} filter.lfs.smudge=git-lfs smudge --skip -- %f +\n`.git/config` {nbsp} {nbsp} {nbsp} filter.lfs.process=git-lfs filter-process --skip +\n=====\n+\n[subs=\"verbatim,macros\"]\n.Initialize git and git-lfs\n----\npass:q[~/git-lfs-intro$ *git init*]\npass:q[\u003cfont color=#999999\u003eInitialized empty Git repository in ~/git-lfs-intro/.git/\u003c/font\u003e]\n\n~/git-lfs-intro$ pass:q[*git lfs install*] --local --skip-smudge       \u003c1\u003e \u003c2\u003e\npass:q[\u003cfont color=#999999\u003eUpdated git hooks.\u003c/font\u003e]\npass:q[\u003cfont color=#999999\u003eGit LFS initialized.\u003c/font\u003e]\n\n~/git-lfs-intro$ pass:q[*git lfs track*] '*.pdf'                       \u003c3\u003e\npass:q[\u003cfont color=#999999\u003eTracking \"*.pdf\"\u003c/font\u003e] \n----\n\u003c1\u003e `--local` sets the \"lfs\" smudge and clean filters in the local repository's git config, instead of the global git config (`~/.gitconfig`).\n\u003c2\u003e `--skip-smudge` skips automatic downloading of objects on clone or pull. This requires a manual \"git lfs pull\" every time a new commit is checked out on your repository.\n\u003c3\u003e `*git lfs track*` starts tracking given pattern(s) through git LFS.\n\n+\n[NOTE]\n====\n`--local` in combination with `--skip-smudge` adds following entries to the local git config at `.git/config`:\n\n=====\n`.git/config` {nbsp} {nbsp} {nbsp} filter.lfs.smudge=git-lfs smudge --skip -- %f +\n`.git/config` {nbsp} {nbsp} {nbsp} filter.lfs.process=git-lfs filter-process --skip +\n`.git/config` {nbsp} {nbsp} {nbsp} filter.lfs.required=true +\n`.git/config` {nbsp} {nbsp} {nbsp} filter.lfs.clean=git-lfs clean -- %f +\n=====\n\n====\n\n. Create 'git-lfs' man-pages pdfs\n+\n.Create data to track with LFS\n[subs=\"verbatim,macros\"]\n----\npass:q[~/git-lfs-intro$ *apropos*. | *awk* '{print $1}' | *grep* git-lfs | while read in; do *man* -t \u003cfont color=#ee00ff\u003e\"$in\"\u003c/font\u003e | *ps2pdf* - \u003cfont color=#ee00ff\u003e\"$in\"\u003c/font\u003e.pdf; done]\npass:q[~/git-lfs-intro$ *ls*]\npass:q[\u003cfont color=#999999\u003egit-lfs-checkout.pdf       git-lfs-config.pdf      git-lfs-fetch.pdf           git-lfs-install.pdf    git-lfs-logs.pdf\u003c/font\u003e]\npass:q[\u003cfont color=#999999\u003egit-lfs.pdf                git-lfs-post-merge.pdf  git-lfs-pull.pdf            git-lfs-status.pdf     git-lfs-unlock.pdf\u003c/font\u003e]\npass:q[\u003cfont color=#999999\u003egit-lfs-clean.pdf          git-lfs-env.pdf         git-lfs-filter-process.pdf  git-lfs-lock.pdf       git-lfs-ls-files.pdf\u003c/font\u003e]\npass:q[\u003cfont color=#999999\u003egit-lfs-pointer.pdf        git-lfs-pre-push.pdf    git-lfs-push.pdf            git-lfs-track.pdf      git-lfs-untrack.pdf\u003c/font\u003e]\npass:q[\u003cfont color=#999999\u003egit-lfs-clone.pdf          git-lfs-ext.pdf         git-lfs-fsck.pdf            git-lfs-locks.pdf      git-lfs-migrate.pdf\u003c/font\u003e]\npass:q[\u003cfont color=#999999\u003egit-lfs-post-checkout.pdf  git-lfs-prune.pdf       git-lfs-smudge.pdf          git-lfs-uninstall.pdf  git-lfs-update.pdf\u003c/font\u003e]\n----\n\n. Add files and `.gitattributes` and commit \n+\n.Commit files\n[subs=\"verbatim,macros\"]\n----\npass:q[~/git-lfs-intro$ *git add* .gitattributes \u003cfont color=#ee00ff\u003e\"*.pdf\"\u003c/font\u003e]\npass:q[~/git-lfs-intro$ *git commit* -m \u003cfont color=#ee00ff\u003e\"Initial commit\"\u003c/font\u003e]\n----\n\n\n\n\n== Clone repository\n\n\nTo prevent lfs from downloading or cloning LFS tracked files _globally_ enter:\n\n.Configure skipping LFS tracked files\n[subs=\"verbatim,macros\"]\n----\npass:q[$ *git lfs install* --skip-smudge]\n----\n\nThis will prevent downloading lfs files when cloning repositories. \nIf you `clone` this repository now, by entering the command below, git will download only a _pointer_ to the lfs file (named just as the original file).\n\n\nTo clone this LFS repository enter:\n[subs=\"verbatim,macros\"]\n.Clone the repository\n----\npass:q[~/temp$ *git clone* \u003ca href=https://github.com/sabicalija/git-lfs-intro.git\u003ehttps://github.com/sabicalija/git-lfs-intro.git\u003c/a\u003e]\n----\n\n/////\n[NOTE]\n=====\nThis repository is set up with `--local --skip-smudge`.\n\nFiles tracked with git LFS will not be downloaded or cloned. +\nUse `git lfs pull` or `git lfs pull --include=filename` to pull all or single files, respecitively.\n=====\n/////\n\n\n== Load lfs file\n\nYou can download all or single files by entering following command:\n\n* *Single file*\n+\n[subs=\"verbatim,macros\"]\n.Pull single LFS tracked file\n----\npass:q[~/temp/git-lfs-intro$ *git lfs pull* \u003cfont color=#0066ff\u003e--include\u003c/font\u003e=filename]\n----\n+\nTo download the main git-lfs manpage pdf enter\n+\n[subs=\"verbatim,macros\"]\n.Pull file \"git-lfs.pdf\"\n----\npass:q[~/temp/git-lfs-intro$ *git lfs pull* \u003cfont color=#0066ff\u003e--include\u003c/font\u003e=\u003cfont color=#ee00ff\u003e\"git-lfs.pdf\"\u003c/font\u003e]\npass:q[\u003cfont color=#999999\u003eGit LFS: (1 of 1 files) 18.97 KB / 18.97 KB\u003c/font\u003e]\n----\n\n+\n[NOTE]\n=====\nStage the newly downloaded file. This gives git the chance, to see that the \"new\" file is actually already tracked by git-lfs.\n\n[subs=\"verbatim,macros\"]\n.Restore respository state\n----\npass:q[~/temp/git-lfs-intro$ *git add* git-lfs.pdf]\n----\n\nor reset the repository by entering:\n[subs=\"verbatim,macros\"]\n.Restore (reset) repostiory state\n----\npass:q[~/temp/git-lfs-intro$ *git reset* HEAD .]\n----\n=====\n\n\n* *All files*\n+\n[subs=\"verbatim,macros\"]\n.Pull all LFS tracked files\n----\npass:q[~/temp/git-lfs-intro$ *git lfs pull*]\npass:q[\u003cfont color=#999999\u003eGit LFS: (29 of 29 files) 475.39 KB / 475.39 KB\u003c/font\u003e]\n----\n\n== Convert lfs file to pointer\n\nIn case you don't need the original binary anymore, you can convert it back to a pointer file.\nTo achieve this enter following commands:\n\n[subs=\"verbatim,macros\"]\n.Convert LFS tracked binary to pointer\n----\npass:q[~/temp/git-lfs-intro$ *git lfs pointer* --file=filename]\npass:q[\u003cfont color=#999999\u003eGit LFS pointer for filename\u003c/font\u003e]\n\npass:q[\u003cfont color=#999999\u003eversion\u003c/font\u003e \u003ca href=https://git-lfs.github.com/spec/v1\u003ehttps://git-lfs.github.com/spec/v1\u003c/a\u003e]\npass:q[\u003cfont color=#999999\u003eoid sha256:dc26a22ac0dceb6ce27dd870a1a9f6791f45d4fbc75499093779de3d30b7b5ba\u003c/font\u003e]\npass:q[\u003cfont color=#999999\u003esize 19425\u003c/font\u003e]\n----\n\nThis will output the generated pointer to the `stdout`.\n_Copy_ the content to a new file, _delete_ the downloaded LFS file, and rename the newly created pointer file using it's original name.\nNow, stage the file again, to restore the repository's state.\n\nTo convert the main `git-lfs.pdf` manpage pdf to a pointer file enter:\n\n[subs=\"verbatim,macros\"]\n.Convert \"git-lfs.pdf\" to pointer\n----\npass:q[~/temp/git-lfs-intro$ *git lfs pointer* --file=\u003cfont color=#ee00ff\u003e\"git-lfs.pdf\"\u003c/font\u003e \u003e git-lfs.pdf.pt]\npass:q[\u003cfont color=#999999\u003eGit LFS pointer for git-lfs.pdf\u003c/font\u003e]\n\npass:q[~/temp/git-lfs-intro$ *rm* git-lfs.pdf]\npass:q[~/temp/git-lfs-intro$ *mv* git-lfs.pdf.pt git-lfs.pdf]\npass:q[~/temp/git-lfs-intro$ *git add* git-lfs.pdf]\n----\n\n== Delete a lfs file\n\n[CAUTION]\n=====\nThe files exchanged by a pointer file are removed from the repository, but not from disk. \n=====\n\nTo remove the original binary (tracked by git LFS) locate the file you wish to remove at `.git/lfs/objects` and delete it there. \n\nNOTE: Now, if you want to get the binary again, simply enter `git lfs pull --include=filename`.\n\nYou can use the `oid` from the pointer file, to print the location of the binary file to `stdout` or delete the file \"automatically\".\n\n\n.Read the oid from pointer file\n[subs=\"verbatim,macros\"]\n-----\n\npass:q[~/temp/git-lfs-intro$ *cat* git-lfs.pdf]\npass:q[\u003cfont color=#999999\u003eversion \u003c/font\u003e\u003ca href=https://git-lfs.github.com/spec/v1\u003ehttps://git-lfs.github.com/spec/v1\u003c/a\u003e]\npass:q[\u003cfont color=#999999\u003eoid sha256:dc26a22ac0dceb6ce27dd870a1a9f6791f45d4fbc75499093779de3d30b7b5ba\u003c/font\u003e]\npass:q[\u003cfont color=#999999\u003esize 19425\u003c/font\u003e]\n\npass:q[~/temp/git-lfs-intro$ *cat* git-lfs.pdf | *grep* oid]\npass:q[\u003cfont color=#ff0000\u003eoid\u003c/font\u003e \u003cfont color=#999999\u003esha256:dc26a22ac0dceb6ce27dd870a1a9f6791f45d4fbc75499093779de3d30b7b5ba\u003c/font\u003e]\n\npass:q[~/temp/git-lfs-intro$ *cat* git-lfs.pdf | *grep* oid | *cut* -d \u003cfont color=#ee00ff\u003e\":\"\u003c/font\u003e -f 2]\npass:q[\u003cfont color=#999999\u003edc26a22ac0dceb6ce27dd870a1a9f6791f45d4fbc75499093779de3d30b7b5ba\u003c/font\u003e]\n\n-----\n\n.Print binary file location to terminal\n[subs=\"verbatim,macros\"]\n-----\npass:q[~/temp/git-lfs-intro$ *find* . | *grep* $(*cat* git-lfs.pdf | *grep* oid | *cut* -d \u003cfont color=#ee00ff\u003e\":\"\u003c/font\u003e -f 2)]\npass:q[\u003cfont color=#999999\u003e./.git/lfs/objects/dc/26/\u003c/font\u003e\u003cfont color=#ff0000\u003edc26a22ac0dceb6ce27dd870a1a9f6791f45d4fbc75499093779de3d30b7b5ba\u003c/font\u003e]\n-----\n\nYou could also use following short-cut, but be carefull.\nThe commands need to be entered subsequently.\n\n.Print binary file location to terminal (short cut)\n[subs=\"verbatim,macros\"]\n-----\npass:q[~/temp/git-lfs-intro$ *cat* git-lfs.pdf | *grep* oid | *cut* -d \u003cfont color=#ee00ff\u003e\":\"\u003c/font\u003e -f 2]\npass:q[\u003cfont color=#999999\u003edc26a22ac0dceb6ce27dd870a1a9f6791f45d4fbc75499093779de3d30b7b5ba\u003c/font\u003e]\n\npass:q[~/temp/git-lfs-intro$ *find* . | *grep* $(!!)]\npass:q[\u003cfont color=#999999\u003efind . | grep $(cat git-lfs.pdf | grep oid | cut -d \":\" -f 2)\u003c/font\u003e]\npass:q[\u003cfont color=#999999\u003e./.git/lfs/objects/dc/26/\u003c/font\u003e\u003cfont color=#ff0000\u003edc26a22ac0dceb6ce27dd870a1a9f6791f45d4fbc75499093779de3d30b7b5ba\u003c/font\u003e]\n-----\n\n[NOTE]\n=====\nThe location of the binary, or the names of the folders where it is stored matches a pattern of the oid hash value.\n=====\n\n.Delete binary file automatically\n[subs=\"verbatim,macros\"]\n-----\npass:q[~/temp/git-lfs-intro$ *rm* $(*find* . | *grep* $(*cat* git-lfs.pdf | *grep* oid | *cut* -d \u003cfont color=#ee00ff\u003e\":\"\u003c/font\u003e -f 2))]\n-----\n\nor with a short cut, just like above:\n\n.Delete binary file automatically (short cut)\n[subs=\"verbatim,macros\"]\n-----\npass:q[~/temp/git-lfs-intro$ *cat* git-lfs.pdf | *grep* oid | *cut* -d \u003cfont color=#ee00ff\u003e\":\"\u003c/font\u003e -f 2]\npass:q[\u003cfont color=#999999\u003edc26a22ac0dceb6ce27dd870a1a9f6791f45d4fbc75499093779de3d30b7b5ba\u003c/font\u003e]\n\npass:q[~/temp/git-lfs-intro$ *find* . | grep $(!!)]\npass:q[\u003cfont color=#999999\u003efind . | grep $(cat git-lfs.pdf | grep oid | cut -d \":\" -f 2)\u003c/font\u003e]\npass:q[\u003cfont color=#999999\u003e./.git/lfs/objects/dc/26/\u003c/font\u003e\u003cfont color=#ff0000\u003edc26a22ac0dceb6ce27dd870a1a9f6791f45d4fbc75499093779de3d30b7b5ba\u003c/font\u003e]\n\npass:q[~/temp/git-lfs-intro$ *rm* $(!!)]\npass:q[\u003cfont color=#999999\u003erm $(find . | grep $(cat git-lfs.pdf | grep oid | cut -d \":\" -f 2))\u003c/font\u003e]\n\n~/temp/git-lfs-intro$ \n-----\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabicalija%2Fgit-lfs-intro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsabicalija%2Fgit-lfs-intro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabicalija%2Fgit-lfs-intro/lists"}