{"componentChunkName":"component---src-pages-markdown-remark-fields-slug-js","path":"/engineering/how-git-local-repository-works/","result":{"data":{"markdownRemark":{"id":"43de49ea-9c68-55fd-b5cc-3cb805cb98f5","excerpt":"How Git Local Repository Works Let's understand how git set up a local repository\nOnce we initialize or clone any git project that will set up a local project…","html":"<h1 id=\"how-git-local-repository-works\" style=\"position:relative;\"><a href=\"#how-git-local-repository-works\" aria-label=\"how git local repository works permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How Git Local Repository Works</h1>\n<p>Let's understand how git set up a local repository\nOnce we initialize or clone any git project that will set up a local project environment.</p>\n<p>that whole environment will look like the below picture </p>\n<p><img src=\"/ca0bd0ca191bde71b10a2286f670279a/localrepository.webp\" alt=\"git-local-environment\"></p>\n<p><strong>Project Folder</strong>: The main folder consists of a workspace and local repository</p>\n<p><strong>Work Directory</strong>: Inside Project Folder where we actually work,  we keep all files and perform many operations like addition, update, deletion of files</p>\n<p><strong>Local Repository</strong>: Here we don't actually change anything, this is handled automatically by git. this consists <strong>staging area</strong>, <strong>commit history</strong>, <strong>stash area</strong> etc.</p>\n<p>Let's get into it step by step and see how we perform command or action and behind the scene, git do its own activity. </p>\n<ul>\n<li>\n<p>Step 1. Git clone and project:\n<img src=\"/2a3f3511e49540833272a6937fcd9df1/3.webp\" alt=\"3\"></p>\n<p><img src=\"/ae96ccfa2196280f1e51b9e7ae68d852/4.webp\" alt=\"4\"></p>\n</li>\n<li>\n<p>Step 2. Explore what we got in repository\n<img src=\"/49d856745dcecb8cb4b279de2bbc4b26/5.webp\" alt=\"5\"></p>\n<p><img src=\"/8aa07bda67492a31a8fc37da826f8782/6.webp\" alt=\"6\"></p>\n</li>\n<li>\n<p>Step 3. Do some modification in a files\n<img src=\"/18848b433091ff080860f1d5f9f27b9a/7.webp\" alt=\"7\"></p>\n<p><img src=\"/9315e36658a481adb87f4e34d4aab9c3/8.webp\" alt=\"8\"></p>\n</li>\n<li>\n<p>Step 4. Add this file in to staging (ready for commit)\n<img src=\"/4e19001d79a97c6278b9cd21d55ec88e/9.webp\" alt=\"9\"></p>\n<p><img src=\"/8850a9aa0b8d59b2a2f95d0c1029be95/10.webp\" alt=\"10\"></p>\n</li>\n<li>\n<p>Step 5. Commit the file\n<img src=\"/f94304e157ef9cb1c47fe19d3b942fea/11.webp\" alt=\"11\"></p>\n<p><img src=\"/a4164b6d6f6551a162221765406cd592/12.webp\" alt=\"12\"></p>\n</li>\n<li>\n<p>Step 6. Push the changes\n<img src=\"/6d8c26bac6bcdf0eaf4f719dcb1dc0f2/13.webp\" alt=\"13\"></p>\n<p><img src=\"/570b8a6bf65323664b73e7c81314e956/14.webp\" alt=\"14\"></p>\n</li>\n</ul>\n<p>Hope this makes clear how git handling things at the local repository.</p>\n<blockquote>\n<p>Note: <a href=\"https://compile7.org/decompile/how-to-automate-workflows-with-git-hooks/\">Click here to learn how you can automate your Git workflows with Hooks</a></p>\n</blockquote>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n</style>","headings":[{"value":"How Git Local Repository Works","depth":1}],"fields":{"slug":"/engineering/how-git-local-repository-works/"},"frontmatter":{"metatitle":null,"metadescription":null,"description":"In this article, I will talk about how Git Local Repository Works","title":"How Git Local Repository Works","canonical":null,"date":"April 12, 2021","updated_date":null,"tags":["GIT"],"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/4fd42535cde3fddc0451ae0d89c15a26/2ad7f/git.webp","srcSet":"/static/4fd42535cde3fddc0451ae0d89c15a26/1c9b5/git.webp 200w,\n/static/4fd42535cde3fddc0451ae0d89c15a26/f1752/git.webp 400w,\n/static/4fd42535cde3fddc0451ae0d89c15a26/2ad7f/git.webp 800w,\n/static/4fd42535cde3fddc0451ae0d89c15a26/e7405/git.webp 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Abhimanyu Singh Rathore","github":"abhir9","bio":"He is a fun-loving technocrat, artist, photographer, nature lover, leisure traveler, and developer. He actively develops full-stack apps and programs in Go and various JavaScript frameworks and libraries, especially React.","avatar":null}}}},"pageContext":{"id":"43de49ea-9c68-55fd-b5cc-3cb805cb98f5","fields__slug":"/engineering/how-git-local-repository-works/","__params":{"fields__slug":"engineering"}}},"staticQueryHashes":["1171199041","1384082988","1711371485","1753898100","2100481360","229320306","23180105","528864852"]}