{"id":171,"date":"2024-02-08T13:30:34","date_gmt":"2024-02-08T08:00:34","guid":{"rendered":"https:\/\/www.theunusualsingh.com\/blog\/?p=171"},"modified":"2024-02-08T19:58:20","modified_gmt":"2024-02-08T14:28:20","slug":"mastering-git-basics","status":"publish","type":"post","link":"https:\/\/www.theunusualsingh.com\/blog\/mastering-git-basics","title":{"rendered":"Mastering Git Basics: A Comprehensive Guide to Essential Commands"},"content":{"rendered":"\n<p>Git, a distributed version control system, has become an indispensable tool for software developers and teams. Whether you&#8217;re a beginner or an experienced coder, understanding the basics of Git commands is crucial for effective collaboration and version control. In this blog, we&#8217;ll explore the fundamental Git commands with practical examples to help you navigate the world of version control seamlessly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Initializing a Repository:<\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" data-code=\"git init\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">git<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">init<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>This command initializes a new Git repository in the current directory. It creates a hidden folder called <code><strong>.git<\/strong><\/code> that stores the configuration files and the version history of your project. Running this command is the first step when starting a new project or when converting an existing project into a Git repository.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Cloning a Repository:<\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" data-code=\"git clone &lt;repository_url&gt;\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">git<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">clone<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #C3E88D\">repository_ur<\/span><span style=\"color: #EEFFFF\">l<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>To work with an existing Git repository, you can clone it using this command. Replace <code><strong>&lt;repository_url><\/strong><\/code> with the URL of the repository you want to clone. This is commonly used when you want to collaborate with others or when you need a copy of a project hosted on a remote server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Checking the Status:<\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" data-code=\"git status\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">git<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">status<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>This command provides information about the current state of your working directory. It shows which files are untracked, modified, or staged. Checking the status before and after making changes helps you understand the status of your project and what needs to be committed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Adding Changes:<\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" data-code=\"git add &lt;file_name_1&gt; &lt;file_name_2&gt; # for adding individual files\ngit add . # for adding all files\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">git<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">add<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #C3E88D\">file_name_<\/span><span style=\"color: #89DDFF\">1&gt;<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #C3E88D\">file_name_<\/span><span style=\"color: #89DDFF\">2&gt;<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #545454; font-style: italic\"># for adding individual files<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">git<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">add<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">.<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #545454; font-style: italic\"># for adding all files<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Before committing changes, you need to stage them using the <code>git add<\/code> command. The dot (<code>.<\/code>) represents all files in the current directory. You can replace the dot with specific file names to stage only those files. Staging is the process of preparing changes for a commit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Committing Changes:<\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" data-code=\"git commit -m &quot;Your commit message here&quot;\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">git<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">commit<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-m<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&quot;<\/span><span style=\"color: #C3E88D\">Your commit message here<\/span><span style=\"color: #89DDFF\">&quot;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Once changes are staged, commit them to the repository with a descriptive message. The commit message should provide a concise summary of the changes made. Commits are like snapshots of your project at a specific point in time, making it easy to track the project&#8217;s history.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6. Viewing Commit History:<\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" data-code=\"git log\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">git<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">log<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The <code><strong>git log<\/strong><\/code> command displays a log of all commits in reverse chronological order. It includes information such as the commit hash, author, date, and commit message. This is useful for understanding the project&#8217;s development timeline and reviewing changes made by different contributors.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">7. Branching:<\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" data-code=\"git branch &lt;branch_name&gt;\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">git<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">branch<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #C3E88D\">branch_nam<\/span><span style=\"color: #EEFFFF\">e<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Create a new branch with this command. Branches allow you to work on different features or bug fixes independently. You can switch between branches to isolate changes and merge them later. Branching is a powerful feature that enables parallel development.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" data-code=\"git checkout &lt;branch_name&gt;\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">git<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">checkout<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #C3E88D\">branch_nam<\/span><span style=\"color: #EEFFFF\">e<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Switch to an existing branch using this command.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" data-code=\"git checkout -b &lt;branch_name&gt;\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">git<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">checkout<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">-b<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #C3E88D\">branch_nam<\/span><span style=\"color: #EEFFFF\">e<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Create a new branch and switch to it in one step.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">8. Merging Branches:<\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" data-code=\"git checkout main\ngit merge &lt;branch_name&gt;\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">git<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">checkout<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">main<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">git<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">merge<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #C3E88D\">branch_nam<\/span><span style=\"color: #EEFFFF\">e<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>After making changes in a feature branch, you may want to merge those changes back into the main branch. This ensures that the main branch reflects the latest updates from all contributors. The <code><strong>git merge<\/strong><\/code> command combines changes from one branch into another.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">9. Pulling Changes:<\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" data-code=\"git pull origin main\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">git<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">pull<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">origin<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">main<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>If you&#8217;re working in a team, use <code><strong>git pull<\/strong><\/code> to fetch and merge changes from the remote repository. This ensures that your local branch is up-to-date with the latest changes made by others.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">10. Pushing Changes:<\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2e2e2e;color:#d5ffff\">Bash<\/span><span role=\"button\" tabindex=\"0\" data-code=\"git push origin &lt;branch_name&gt;\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-darker\" style=\"background-color: #212121\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">git<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">push<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #C3E88D\">origin<\/span><span style=\"color: #EEFFFF\"> <\/span><span style=\"color: #89DDFF\">&lt;<\/span><span style=\"color: #C3E88D\">branch_nam<\/span><span style=\"color: #EEFFFF\">e<\/span><span style=\"color: #89DDFF\">&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>To share your local changes with the remote repository, use <code>git push<\/code>. This command uploads your commits to the specified branch on the remote server. Other team members can then pull these changes into their local repositories.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In conclusion, these fundamental Git commands provide a solid foundation for version control in software development. Regular use of these commands will help you manage your project&#8217;s history, collaborate effectively with others, and streamline your development workflow.<\/p>\n\n\n\n<div class=\"tus-card tus-callout-card tus-callout-card-green\">\n    <div class=\"tus-callout-emoji\">\ud83d\udca1<\/div>\n    <div class=\"tus-callout-text\">\n        Here are a few essential takeaways:\n        <br>\n        <ul>\n            <li><strong>Commit Often, Commit Descriptively:<\/strong> Making small, frequent commits with clear messages helps in creating a detailed and understandable version history of your project. This practice facilitates collaboration and makes it easier to pinpoint changes.<\/li>\n            <li><strong>Branch Strategically:<\/strong> Understanding how to use branches is essential. It allows you to work on new features or bug fixes without affecting the main branch. This strategy promotes a clean and organized project structure.<\/li>\n            <li><strong>Regularly Pull and Push:<\/strong> Pulling changes from the remote repository keeps your local repository up-to-date with the latest developments. Pushing your changes ensures that your contributions are shared with the team. This bidirectional communication is vital for collaborative projects.<\/li>\n            <li><strong>Use git status Frequently:<\/strong> The git status command provides a snapshot of your current working directory status. Regularly checking the status helps you keep track of changes, ensuring that you are aware of modifications before committing them.<\/li>\n            <li><strong>Collaborate Effectively:<\/strong> Communication is key in collaborative projects. Understanding branching strategies, resolving conflicts promptly, and ensuring a shared understanding of the Git workflow with your team ensures a smooth collaborative process.<\/li>\n        <\/ul>\n        By focusing on these aspects, you&#8217;ll be better equipped to manage your projects efficiently and work seamlessly with others. <strong>Good Luck!<\/strong>\n    <\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Git, a distributed version control system, has become an indispensable tool for software developers and teams. Whether you&#8217;re a beginner or an experienced coder, understanding the basics of Git commands is crucial for effective collaboration and version control. In this blog, we&#8217;ll explore the fundamental Git commands with practical examples to help you navigate the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":180,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[114],"tags":[115],"class_list":["post-171","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software-development","tag-git"],"_links":{"self":[{"href":"https:\/\/www.theunusualsingh.com\/blog\/wp-json\/wp\/v2\/posts\/171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.theunusualsingh.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.theunusualsingh.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.theunusualsingh.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.theunusualsingh.com\/blog\/wp-json\/wp\/v2\/comments?post=171"}],"version-history":[{"count":2,"href":"https:\/\/www.theunusualsingh.com\/blog\/wp-json\/wp\/v2\/posts\/171\/revisions"}],"predecessor-version":[{"id":173,"href":"https:\/\/www.theunusualsingh.com\/blog\/wp-json\/wp\/v2\/posts\/171\/revisions\/173"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.theunusualsingh.com\/blog\/wp-json\/wp\/v2\/media\/180"}],"wp:attachment":[{"href":"https:\/\/www.theunusualsingh.com\/blog\/wp-json\/wp\/v2\/media?parent=171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.theunusualsingh.com\/blog\/wp-json\/wp\/v2\/categories?post=171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.theunusualsingh.com\/blog\/wp-json\/wp\/v2\/tags?post=171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}