{"id":890,"date":"2024-07-13T19:52:17","date_gmt":"2024-07-13T19:52:17","guid":{"rendered":"https:\/\/www.cmsgalaxy.com\/blog\/?p=890"},"modified":"2024-07-13T19:52:20","modified_gmt":"2024-07-13T19:52:20","slug":"git-full-concept","status":"publish","type":"post","link":"https:\/\/www.cmsgalaxy.com\/blog\/git-full-concept\/","title":{"rendered":"Git Full Concept"},"content":{"rendered":"\n<p>Git is a distributed version control system designed to handle everything from small to very large projects with speed and efficiency. It allows multiple developers to work on a project simultaneously without interfering with each other&#8217;s work.<\/p>\n\n\n\n<p><strong>Core Concepts of Git<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Repository (Repo):<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A repository is a directory which contains your project work, as well as a few files (hidden by default) which are used by Git to track changes.<\/li>\n\n\n\n<li>You can create a repository locally on your computer, and you can also push this repository to a remote location (like GitHub, GitLab, or Bitbucket)<\/li>\n<\/ul>\n\n\n\n<p>2. <strong>Branches:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A branch in Git is simply a lightweight movable pointer to one of these commits.<\/li>\n\n\n\n<li>The default branch name in Git is <code>main<\/code> (formerly <code>master<\/code>).<\/li>\n\n\n\n<li>Branching allows you to diverge from the main line of development and continue to do work without messing with that main line.<\/li>\n<\/ul>\n\n\n\n<p>3. <strong>Commits:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A commit is a snapshot of your repository at a specific point in time.<\/li>\n\n\n\n<li>Every commit in Git has a unique ID (SHA-1 hash).<\/li>\n<\/ul>\n\n\n\n<p>4. <strong>Staging Area (Index):<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit.<\/li>\n\n\n\n<li>It&#8217;s sometimes referred to as the index, but it&#8217;s more accurately referred to as the staging area.<\/li>\n<\/ul>\n\n\n\n<p>5. <strong>Working Directory:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The working directory is the area where you are currently working. It consists of files that you are modifying, which are not yet committed.<\/li>\n<\/ul>\n\n\n\n<p><strong>Basic Git Commands:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>git init:<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Initializes a new Git repository.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">git init<\/pre>\n\n\n\n<p>2. <strong>git clone:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Clone a repository into a new directory.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">git clone https:\/\/github.com\/user\/repo.git<\/pre>\n\n\n\n<p>3. <strong>git add:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add file contents to the index (staging area).<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">git add &lt;filename><\/pre>\n\n\n\n<p>4. <strong>git commit:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Record changes to the repository.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">git commit -m \"Commit message\"<\/pre>\n\n\n\n<p>5. <strong>git status:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Show the working tree status.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">git status<\/pre>\n\n\n\n<p>6. <strong>git log:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Show commit logs.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">git log<\/pre>\n\n\n\n<p>7. <strong>git branch:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>List, create, or delete branches.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">git branch<\/pre>\n\n\n\n<p>8. <strong>git checkout:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Switch branches or restore working tree files.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">git checkout &lt;branch_name><\/pre>\n\n\n\n<p>9. <strong>git merge:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Join two or more development histories together.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">git merge &lt;branch_name><\/pre>\n\n\n\n<p>10. <strong>git pull:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Fetch from and integrate with another repository or a local branch.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">git pull origin main<\/pre>\n\n\n\n<p>11. <strong>git push:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Update remote refs along with associated objects.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">git push origin main<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Git is a distributed version control system designed to handle everything from small to very large projects with speed and<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-890","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/posts\/890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/comments?post=890"}],"version-history":[{"count":1,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/posts\/890\/revisions"}],"predecessor-version":[{"id":892,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/posts\/890\/revisions\/892"}],"wp:attachment":[{"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/media?parent=890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/categories?post=890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/tags?post=890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}