{"id":8736,"date":"2025-03-24T19:44:54","date_gmt":"2025-03-24T14:14:54","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=8736"},"modified":"2025-03-24T19:44:59","modified_gmt":"2025-03-24T14:14:59","slug":"git-fundamentals","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/git-fundamentals\/","title":{"rendered":"Git Fundamentals"},"content":{"rendered":"\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">Git<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1. <strong>What is Git?<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Git is a distributed version control system for tracking changes in code, enabling collaboration, and managing project history.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Every user has a full local copy of the repository.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2. <strong>Key Concepts<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Repository (Repo):<\/strong> Where your project files and history live (local or remote).<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Commit:<\/strong> A snapshot of changes with a unique hash.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Branch:<\/strong> A separate line of development (default is often <code>main<\/code>).<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Merge:<\/strong> Combines changes from one branch into another.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Rebase:<\/strong> Moves or &#8220;replays&#8221; commits from one branch onto another, creating a linear history.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Staging Area:<\/strong> Prepares changes for a commit.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Clone:<\/strong> Copies a remote repo locally.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Push\/Pull:<\/strong> Syncs changes with a remote repo.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3. <strong>Basic Git Workflow<\/strong><\/h4>\n\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>git init: Starts a new repo.\n\ngit status: Checks the current state.\n\ngit add &lt;file&gt; or git add .: Stages changes.\n\ngit commit -m \"message\": Commits staged changes.\n\ngit push  :Syncs changes with a remote repo.\n\ngit log: Views commit history.<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">4. <strong>Branching and Merging<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\"><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>Create Branch: git branch &lt;branch-name&gt;\n\nSwitch Branch: git checkout &lt;branch-name&gt; (or git switch &lt;branch-name&gt;)\n\nMerge: git merge &lt;branch-name&gt;\n\nDelete Branch: git branch -d &lt;branch-name&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">5. <strong>Rebasing<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>What is Rebasing?<\/strong> Rebasing rewrites commit history by moving your branch\u2019s commits onto the tip of another branch. It avoids merge commits for a cleaner history.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Command:<\/strong> <code>git rebase &lt;branch-name&gt;<\/code> (e.g., <code>git rebase main<\/code> applies your current branch\u2019s commits on top of <code>main<\/code>).<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Interactive Rebasing:<\/strong> <code>git rebase -i &lt;commit-hash&gt;<\/code> lets you edit, squash, or reorder commits.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Resolve Conflicts:<\/strong> If conflicts arise, fix them, then <code>git rebase --continue<\/code>.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">6. <strong>Remote Repositories<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\"><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone &lt;url&gt;: Copies a remote repo.\n\ngit remote add origin &lt;url&gt;: Links to a remote.\n\ngit push origin &lt;branch-name&gt;: Uploads changes.\n\ngit pull origin &lt;branch-name&gt;: Downloads updates.<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">7. <strong>Undoing Changes<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\"><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>git restore &lt;file&gt;: Discards unstaged changes.\n\ngit reset --soft HEAD^: Undoes last commit, keeps changes.\n\ngit revert &lt;commit-hash&gt;: Creates a new commit undoing a previous one.<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">8. <strong>Common Commands<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\"><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>git diff: Shows changes.\n\ngit fetch: Downloads remote updates without merging.\n\ngit stash: Shelves uncommitted changes.<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Git 1. What is Git? 2. Key Concepts 3. Basic Git Workflow 4. Branching and Merging 5. Rebasing 6. Remote [&hellip;]<\/p>\n","protected":false},"author":514,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[],"class_list":["post-8736","post","type-post","status-publish","format-standard","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phns3A-2gU","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8736","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/514"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=8736"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8736\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=8736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=8736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=8736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}