Git Checkout https://www.novicedev.com/ en How to Create a new GIT Branch from a Tag? https://www.novicedev.com/blog/how-create-new-git-branch-tag <span>How to Create a new GIT Branch from a Tag?</span> <div class="field field--name-field-image field--type-image field--label-hidden field-item"> <img loading="lazy" src="/sites/novicedev/files/styles/blog_cover/public/2022-09/create-git-branch-from-tag_0.png?itok=hC7ESngi" width="772" height="435" alt="How to Create a new GIT Branch from a Tag?" title="How to Create a new GIT Branch from a Tag?" class="image-field" /> </div> <span><span>noviceadmin</span></span> <span>Sun, 09/18/2022 - 15:10</span> <div> <div class="field-item"> <div class="paragraph paragraph--type--text paragraph--view-mode--default"> </div> </div> </div> <div class="field field--name-body field--type-text-with-summary field--label-hidden field-item"><p><strong>A new GIT branch can be created from a tag through the “git checkout” command with the “-b” option followed by a new branch name and tag name.</strong></p> <pre> <code class="language-bash">$ git checkout -b &lt;new-branch&gt; &lt;tag-name&gt;</code></pre> <p> </p> <h2>Why Create Git Branch from a Tag</h2> <p><a href="https://www.novicedev.com/blog/how-create-git-tags-examples">GIT tags are created</a> to mark a specific point in git history and then deployed. But sometimes you might want to debug the deployed code and the best way is to create a new GIT branch from that tag.</p> <p> </p> <h2>How to Create Git Branch from a Tag</h2> <p>Let’s say you have deployed tag v2.0 on production and now you have some issues after the deployment.</p> <p>Now creating a debug branch from the tag v2.0 will be the best way to make sure you have the exact code which is deployed on production.</p> <p>Now let's go through each step one by one to create a new branch from the correct tag.</p> <h3>1. Get the tag</h3> <p>Make sure you fetch all the tags from your remote repository with the "git fetch" command</p> <pre> <code class="language-bash">$ git fetch --all --tags</code></pre> <h3>2. Confirm the tag</h3> <p>Now confirm that you have fetched the required tag v2.0 from which you want to create the branch.</p> <pre> <code class="language-bash">$ git tag -l v2.0 v1.0</code></pre> <h3>3. Create a new branch from the tag</h3> <p>After confirming that tag v2.0 fetch properly, we can now run the "git checkout" command to create the new branch from that tag.</p> <pre> <code class="language-bash">$ git checkout -b debug-tag-2-0 v2.0</code></pre> <p>Now we have a new branch "debug-tag-2-0" ready for debugging on local.</p> <p> </p> <h2><strong>Conclusion</strong></h2> <p>In this tutorial, we learned why we might need to create a new git branch from a tag for debugging and how this can be achieved with the "git checkout" command.</p> </div> <div class="node-taxonomy-container"> <ul class="taxonomy-terms"> <li class="taxonomy-term"><a href="/topic/git" hreflang="en">Git</a></li> <li class="taxonomy-term"><a href="/topic/git-checkout" hreflang="en">Git Checkout</a></li> <li class="taxonomy-term"><a href="/topic/git-tag" hreflang="en">Git Tag</a></li> </ul> </div> <!--/.node-taxonomy-container --> <section id="node-article-comment" id="comments"> <h2 class="comments-title">Comments</h2> <article data-comment-user-id="0" id="comment-3025" class="js-ajax-comments-id-3025 js-comment comment comment-by-anonymous"> <header class="comment-header"> <div class="comment-user-picture"> </div><!-- /comment-user-picture --> <div class="comment-meta"> <h3 class="comment-title"><a href="/comment/3025#comment-3025" class="permalink" rel="bookmark" hreflang="en">Hello novicedev.com…</a></h3> <p><span>Christine Fuller</span> Sat, 03/11/2023 - 04:38 <mark class="hidden" data-comment-timestamp="1684509156"></mark></p> </div><!-- /comment-meta --> </header> <div class="comment-body"> <div class="field field--name-comment-body field--type-text-long field--label-hidden field-item"><p>Hello novicedev.com webmaster, Well done!</p> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=3025&amp;1=default&amp;2=en&amp;3=" token="bzaOCQoOyamrUZqA7CE7Mn9ZJFFlnzz5PlJfIuNU9KM"></drupal-render-placeholder> </div> <!-- /.comment-body --> </article> <div class="comment-form-wrap"> <h2 class="add-comment-title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=29&amp;2=comment&amp;3=comment" token="UMnLAd2pwczbhuG_AINUbJsxrKQK2Tp-jz6Pxzped2E"></drupal-render-placeholder> </div> <!--/.comment-form --> </section> Sun, 18 Sep 2022 15:10:55 +0000 noviceadmin 29 at https://www.novicedev.com How to Create a Git Branch (WITH EXAMPLE) https://www.novicedev.com/blog/how-create-git-branch-example <span>How to Create a Git Branch (WITH EXAMPLE)</span> <div class="field field--name-field-image field--type-image field--label-hidden field-item"> <img loading="lazy" src="/sites/novicedev/files/styles/blog_cover/public/2022-09/How%20to%20Create%20a%20Branch%20in%20GIT%3F.png?itok=5IpMD-AV" width="772" height="481" alt="How to Create a Git Branch (WITH EXAMPLE)" title="How to Create a Git Branch (WITH EXAMPLE)" class="image-field" /> </div> <span><span>noviceadmin</span></span> <span>Mon, 09/12/2022 - 03:33</span> <div> <div class="field-item"> <div class="paragraph paragraph--type--text paragraph--view-mode--default"> <div class="field field--name-field-para-text field--type-text-long field--label-hidden field-item"><p>Whenever you start developing a new feature you must start with creating a new branch git. This way you separate your feature changes from other branches.</p> <p><strong>A new branch can be created with the ‘git checkout’ command with the ‘-b’ option and a new branch name as arguments. This will create a new branch from your current branch and also switch the branch to the new branch.</strong></p> <pre> <code class="language-bash">$ git checkout -b &lt;new-branch&gt;</code></pre> <p>But if you don't want to create a new branch from the current branch then you can also pass the base branch as an argument.</p> <pre> <code class="language-bash">$ git checkout -b &lt;new-branch&gt; &lt;base-branch&gt;</code></pre> <p>Once the feature is completed, this new branch can be merged back into the other branch.</p> <h2>Example of creating a GIT branch</h2> <p>Let's take an example, you want to <strong>create a new feature branch</strong> 'feature-2' from the master branch.</p> <h3>1. Checkout master branch (source branch)</h3> <p>First, make sure your current git branch is the master branch. You can check this by running "git branch" or "git branch --show-current" commands</p> <pre> <code class="language-bash">$ git branch feature-1 * master</code></pre> <p>If not, then make sure to checkout the master branch.</p> <pre> <code class="language-bash">$ git checkout master</code></pre> <h3>2. Run the "git checkout" command with "-b" and feature the branch name</h3> <p>Now you can run the GIT checkout command to create a new feature branch "feature-2"</p> <pre> <code class="language-bash">$ git checkout -b feature-2 Switched to a new branch 'feature-2'</code></pre> <p>Once run successfully, the new branch will be created and your current branch will be switched to this new branch.</p> <h3>3. Confirm the new branch</h3> <p>You can verify your new branch by running the ‘git branch’ command.</p> <pre> <code class="language-bash">$ git branch feature-1 * feature-2 master</code></pre> <p> </p> <h2>Conclusion</h2> <p>In this tutorial, we learned to create a new branch in GIT with the "git checkout" command. This can also be achieved with the "git branch" command.</p> <p>A GIT branch is not the only source for creating a new feature branch. A New GIT branch can also be created from <a href="https://www.novicedev.com/blog/create-git-branch-commit">commit SHA</a>, <a href="https://www.novicedev.com/blog/how-create-new-git-branch-tag">a tag</a>, or a remote branch.</p> </div> </div> </div> </div> <div class="node-taxonomy-container"> <ul class="taxonomy-terms"> <li class="taxonomy-term"><a href="/topic/git" hreflang="en">Git</a></li> <li class="taxonomy-term"><a href="/topic/git-checkout" hreflang="en">Git Checkout</a></li> </ul> </div> <!--/.node-taxonomy-container --> <section id="node-article-comment" id="comments"> <div class="comment-form-wrap"> <h2 class="add-comment-title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=26&amp;2=comment&amp;3=comment" token="DlHzb4c3ll6eORQiZAxAlDl2xxGjcquBWx-IdVT-xfk"></drupal-render-placeholder> </div> <!--/.comment-form --> </section> Mon, 12 Sep 2022 03:33:51 +0000 noviceadmin 26 at https://www.novicedev.com