<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Irshad Bluecast</title>
    <description>The latest articles on DEV Community by Irshad Bluecast (@irshadbluecast).</description>
    <link>https://dev.to/irshadbluecast</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F299454%2F46dff379-2e19-4581-8906-ca6058f34b69.jpg</url>
      <title>DEV Community: Irshad Bluecast</title>
      <link>https://dev.to/irshadbluecast</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/irshadbluecast"/>
    <language>en</language>
    <item>
      <title>How to deploy iOS apps to appstore automatically?</title>
      <dc:creator>Irshad Bluecast</dc:creator>
      <pubDate>Tue, 28 Jan 2020 16:49:59 +0000</pubDate>
      <link>https://dev.to/irshadbluecast/how-to-deploy-ios-apps-to-appstore-automatically-46c1</link>
      <guid>https://dev.to/irshadbluecast/how-to-deploy-ios-apps-to-appstore-automatically-46c1</guid>
      <description>&lt;p&gt;Wondering how to push your iOS app to appstore automatically? Originally written by my friend &lt;a href="https://www.linkedin.com/in/vigneswaranav/"&gt;Vigneswaran&lt;/a&gt; - the &lt;a href="https://bluecast.tech/blog/ios-ci-cd-integration-using-gitlab-and-fastlane/"&gt;step-by-step tutorial&lt;/a&gt; detailing about the process of setting up CI/CD pipeline for iOS mobile apps using &lt;strong&gt;Gitlab CI and fastlane&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;In summary, these are the steps you have to follow.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Steps for Manual Gitlab Runner Installation:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2SzEbX51--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bluecast.tech/wp-content/uploads/2019/07/Setting-up-Gitlab-CI-1024x561.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2SzEbX51--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bluecast.tech/wp-content/uploads/2019/07/Setting-up-Gitlab-CI-1024x561.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You need specific runners instead of shared runners provided by Gitlab, for the case iOS Deployments. You can install them in local Mac machines/Mac servers(MacStadium). Below are the steps to configure runners in macOS and OS X.&lt;/p&gt;

&lt;h5&gt;
  
  
  1. Download the binary for your system:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo curl --output /usr/local/bin/gitlab-runner 
https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-amd64
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h5&gt;
  
  
  2. Give it permissions to execute:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo chmod +x /usr/local/bin/gitlab-runner
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;strong&gt;The rest of commands to be executed as the user who will run the Runner.&lt;/strong&gt;(This is a limitation on macOS).  &lt;/p&gt;

&lt;h5&gt;
  
  
  3. Install the Runner as service and start it:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ~
gitlab-runner install
gitlab-runner start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Steps for Registering a Runner:
&lt;/h2&gt;

&lt;h5&gt;
  
  
  1. To register a Runner under macOS, run the below command first.
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gitlab-runner register
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h5&gt;
  
  
  2. Enter your GitLab instance URL when prompted in the next step.
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com )
https://gitlab.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h5&gt;
  
  
  3. Enter the token you obtained to register the Runner:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Please enter the gitlab-ci token for this runner
xxx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j8X2T8zi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bluecast.tech/wp-content/uploads/2019/07/gitlab-register-on-mac.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j8X2T8zi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bluecast.tech/wp-content/uploads/2019/07/gitlab-register-on-mac.png" alt="steps for register in gitlab"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  4. Enter a description for the Runner, you can change this later in GitLab’s UI:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Please enter the gitlab-ci description for this runner
Local Runner
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h5&gt;
  
  
  5. Enter the tags associated with the Runner,you can change this later in GitLab’s UI:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Please enter the gitlab-ci tags for this runner (comma separated):
ios,another-tag
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h5&gt;
  
  
  6. Enter the tags associated with the Runner,you can change this later in GitLab’s UI:
&lt;/h5&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell:
shell
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If everything goes well, you should see activated runners for your project like in the below image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tCo9WYqp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bluecast.tech/wp-content/uploads/2019/07/git-runnner-setup-300x244.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tCo9WYqp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bluecast.tech/wp-content/uploads/2019/07/git-runnner-setup-300x244.png" alt="git-runnner-setup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Adding Our .gitlab.yml:
&lt;/h2&gt;

&lt;p&gt;Now, it’s time to add a sort of config file for running jobs in the GitLab pipelines that triggers on every commit to a particular repo.&lt;/p&gt;

&lt;p&gt;The best practices for git-branching model can be referred from this  &lt;a href="https://nvie.com/posts/a-successful-git-branching-model/"&gt;article&lt;/a&gt;. For the sake of simplicity, let us consider only our “&lt;strong&gt;master&lt;/strong&gt;” branch. We assume that any commit to master repo need to trigger a job in the CI pipeline.&lt;/p&gt;

&lt;p&gt;Let us configure the gitlab.yml file which needs to be placed in the root of the repo.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stages:
  - test_flight

variables:
  LC_ALL: "en_US.UTF-8"
  LANG: "en_US.UTF-8"

before_script:
  - gem install bundler
  - pod install

test_flight_build:
  dependencies: []
  stage: test_flight
  artifacts:
     paths:
       - fastlane/logs
  script:
     - fastlane beta
  tags:
     - ios
  only:
     - master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This configuration fires a job in the CI pipeline of “&lt;strong&gt;master&lt;/strong&gt;” branch alone that executes the job with a stage ”&lt;strong&gt;test_flight&lt;/strong&gt;” which in turn runs the script “&lt;strong&gt;fastlane beta&lt;/strong&gt;” with the given environment variables on the runner “&lt;strong&gt;tagged as ios&lt;/strong&gt;”.&lt;/p&gt;

&lt;p&gt;The specified “before script” as the name suggests is executed before the job and the artifacts available in the specified path once the job is completed successfully.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Installing Fastlane in Mac:
&lt;/h2&gt;

&lt;p&gt;Fastlane setup is the crucial step in the whole process since it is the backbone of the deployment process. To install Fastlane in your system, please go through the below steps: Install the latest Xcode command line tools:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo gem install fastlane -NV
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Install fastlane using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Using RubyGems
sudo gem install fastlane -NV
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Alternatively using Homebrew
brew cask install fastlane
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To start using fastlane in your project, you’ll need to run fastlane init from your project directory in command line.&lt;/p&gt;

&lt;p&gt;fastlane will ask you for some basic configuration and then create a folder called fastlane in your project which will contain mainly two files:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. fastlane/Appfile
&lt;/h4&gt;

&lt;p&gt;This file is straightforward, so you just want to check to make sure that the Apple ID and app ID that you set up earlier are correct.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app_identifier("APP IDENTIFIER") # The bundle identifier of your app
apple_id("APPLE ID") # Your Apple email address
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  2. fastlane/Fastfile
&lt;/h4&gt;

&lt;p&gt;The Fastfile defines the build steps. Since we’re using a lot of the built-in capability of  &lt;em&gt;fastlane&lt;/em&gt;  this is really straightforward. We create a single lane which increments build number,gets certificates, builds, and uploads the new build to TestFlight. Of course, you may want to split these out into different jobs depending on your use case. Each of these steps, get_certificates, get_provisioning_profile,match, gym, and upload_to_testflight are pre-bundled actions already included with  &lt;em&gt;fastlane&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;get_certificates and get_provisioning_profile are actions associated with the  &lt;a href="https://docs.fastlane.tools/codesigning/getting-started/#using-cert-and-sigh"&gt;&lt;em&gt;cert&lt;/em&gt;  and  &lt;em&gt;sigh&lt;/em&gt;&lt;/a&gt;  approach to codesigning; if you’re using  &lt;a href="https://docs.fastlane.tools/codesigning/getting-started/#using-match"&gt;match&lt;/a&gt;,you may need to update this by commenting get_certificates and get_provisioning_profile.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;default_platform(:ios)

platform :ios do
  desc "Build the application"
  lane :beta do
    increment_build_number(
    build_number: latest_testflight_build_number + 1,
    xcodeproj: "${PROJECT_NAME}.xcodeproj"
  )
    get_certificates
    get_provisioning_profile
    # match(type: "appstore",read_only: true)
    gym
    upload_to_testflight
  end
end
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  3. fastlane/Gymfile
&lt;/h4&gt;

&lt;p&gt;This file is optional, but created manually in order to override the default output directory and place the output in the current folder. This makes things a bit easier for CI. You can read more about  &lt;code&gt;gym&lt;/code&gt;  and its options in the  &lt;a href="https://docs.fastlane.tools/actions/gym/"&gt;gym documentation&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;output_directory("./")

clean(true)

scheme("${PROJECT_NAME}")

workspace("${PROJECT_NAME}.xcworkspace")

include_bitcode(true)

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Connecting the Dots for Code signing using fastlane match
&lt;/h2&gt;

&lt;p&gt;Code Signing is the most important aspect of iOS app deployment, we as iOS developers know the pain of handling code signing issues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;“match”&lt;/strong&gt;  creates all required certificates &amp;amp; provisioning profiles and stores them in a separate git repository. Every team member with access to the repo can use those credentials for code signing. match also automatically repairs broken and expired credentials. It’s the easiest way to share signing credentials across team.&lt;/p&gt;

&lt;p&gt;fastlane  &lt;a href="https://docs.fastlane.tools/actions/match"&gt;match&lt;/a&gt;  improves drastically the code signing process,even for small teams as it is the implementation of  &lt;a href="https://codesigning.guide/"&gt;code signing&lt;/a&gt;  concept.&lt;/p&gt;

&lt;p&gt;For initialising match afresh in your project, follow these  &lt;a href="https://docs.fastlane.tools/actions/match/#usage"&gt;steps&lt;/a&gt;. One caveat, is that we need to generate fresh provisioning profiles and certificates.&lt;/p&gt;

&lt;p&gt;But it is a show stop for anyone trying to use it on existing projects. But there is a way to trick fastlane match to use your existing certificates. Try to go through the steps in this  &lt;a href="https://medium.com/@jonathancardoso/using-fastlane-match-with-existing-certificates-without-revoking-them-a325be69dac6"&gt;article&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  And it’s finally ready
&lt;/h4&gt;

&lt;p&gt;There are some special environment variables we need to set to avoid the jobs failing due to 2FA from Apple that were made mandatory recently.&lt;br&gt;&lt;br&gt;
&lt;code&gt;FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD&lt;/code&gt;  and  &lt;code&gt;FASTLANE_SESSION&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In order to authenticate against the App Store for the TestFlight upload,  &lt;em&gt;fastlane&lt;/em&gt;  must be able to authenticate. In order to do this, you need to create an app-specific password to be used by CI. You can read more about this process in  &lt;a href="https://docs.fastlane.tools/best-practices/continuous-integration/#use-of-application-specific-passwords-and-spaceauth"&gt;this documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;FASTLANE_USER&lt;/code&gt;  and  &lt;code&gt;FASTLANE_PASSWORD&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In order for  &lt;a href="https://docs.fastlane.tools/codesigning/getting-started/#using-cert-and-sigh"&gt;&lt;em&gt;cert&lt;/em&gt;  and  &lt;em&gt;sigh&lt;/em&gt;&lt;/a&gt;  to be able to fetch the provisioning profile and certificates on demand, the  &lt;code&gt;FASTLANE_USER&lt;/code&gt;  and  &lt;code&gt;FASTLANE_PASSWORD&lt;/code&gt;  variables must be set. You can read more about this  &lt;a href="https://docs.fastlane.tools/best-practices/continuous-integration/#environment-variables-to-set"&gt;here&lt;/a&gt;. You may not need these if you are using some other approach to signing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Ah!! Kudos to you!!! We have finally configured our own CI/CD workflow with GitLab CI/CD and Fastlane as our primary tools.&lt;/p&gt;

&lt;p&gt;Thanks for reading this article. Hope it proves to be helpful for you for configuring a robust CI/CD workflow for automating your iOS app deployment process.&lt;/p&gt;

&lt;p&gt;Let me know if you face any difficulties in setting up the same.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>ios</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to switch branches in git more easily</title>
      <dc:creator>Irshad Bluecast</dc:creator>
      <pubDate>Wed, 15 Jan 2020 07:34:49 +0000</pubDate>
      <link>https://dev.to/irshadbluecast/how-to-switch-branches-in-git-more-easily-34pf</link>
      <guid>https://dev.to/irshadbluecast/how-to-switch-branches-in-git-more-easily-34pf</guid>
      <description>&lt;p&gt;Switching or changing branches is the most common git command which we developers use a lot. You may be still using &lt;code&gt;git checkout&lt;/code&gt; command for this. But are you aware of the &lt;code&gt;git switch&lt;/code&gt; command which is more easier to change branches in git?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/git/git/blob/master/Documentation/RelNotes/2.23.0.txt"&gt;Git 2.23&lt;/a&gt;  came up with the new ‘ &lt;a href="https://git-scm.com/docs/git-switch"&gt;&lt;strong&gt;git switch&lt;/strong&gt;&lt;/a&gt;  ’ command, which is not a new feature but an additional command to ‘&lt;strong&gt;switch/change branch’&lt;/strong&gt;  feature which is already available in the overloaded  &lt;strong&gt;git checkout&lt;/strong&gt;  command.&lt;/p&gt;

&lt;p&gt;Currently, the all-encompassing command –  &lt;a href="https://git-scm.com/docs/git-checkout"&gt;&lt;strong&gt;git checkout&lt;/strong&gt;&lt;/a&gt;  does many things. It can be used to  &lt;em&gt;switch branches&lt;/em&gt;  and also to  &lt;em&gt;restore the working tree files&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;To separate out the functionalities, the GIT community introduced the new  &lt;strong&gt;git switch branch command&lt;/strong&gt;  which is an attempt to start to scale back to the responsibilities without breaking backward compatibility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SYNTAX:&lt;/strong&gt; &lt;code&gt;git switch &amp;lt;branch-name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  git switch vs checkout
&lt;/h2&gt;

&lt;p&gt;The new ‘experimental’  &lt;strong&gt;git switch&lt;/strong&gt; &lt;strong&gt;branch command&lt;/strong&gt; is meant to provide a better interface by having a clear separation, which helps to alleviate the developers’ confusion when using  &lt;strong&gt;git checkout&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;One such example is  git checkout  which reverses the modifications of an unstaged file and  git checkout  which switches branch.The dilemma is more when the  &lt;strong&gt;&lt;em&gt;filename&lt;/em&gt;&lt;/strong&gt;  and  &lt;strong&gt;&lt;em&gt;branchname&lt;/em&gt;&lt;/strong&gt;  are the same.&lt;/p&gt;

&lt;p&gt;The new commands,  &lt;strong&gt;git restore&lt;/strong&gt;  (takes care of operations that change file), and the  &lt;strong&gt;git switch&lt;/strong&gt;  (takes care of operations that change branches) shares out the responsibilities of  &lt;strong&gt;git checkout&lt;/strong&gt;  in a more intuitive way.&lt;/p&gt;

&lt;p&gt;To read our indepth tutorial with more detailed examples on how to use &lt;code&gt;git switch&lt;/code&gt; command, please visit -&lt;a href="https://bluecast.tech/blog/git-switch-branch/"&gt;https://bluecast.tech/blog/git-switch-branch/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, dont forget to check my previous tutorial on &lt;a href="https://dev.to/irshadbluecast/how-to-use-git-stash-50ao"&gt;git stash&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to use git stash?</title>
      <dc:creator>Irshad Bluecast</dc:creator>
      <pubDate>Tue, 24 Dec 2019 14:26:14 +0000</pubDate>
      <link>https://dev.to/irshadbluecast/how-to-use-git-stash-50ao</link>
      <guid>https://dev.to/irshadbluecast/how-to-use-git-stash-50ao</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gvByw5Af--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/65lzndmh4hq7hexshnu8.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gvByw5Af--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/65lzndmh4hq7hexshnu8.gif" alt="git-stash-video"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  WHY DO WE USE git stash?
&lt;/h2&gt;

&lt;p&gt;If you are a developer who is using git, you surely may have encountered this error a lot of times.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Your local changes to the following files would be overwritten by  &lt;a href="https://bluecast.tech/blog/git-switch-branch/"&gt;checkout&lt;/a&gt;.  &lt;strong&gt;Please commit your changes or stash them&lt;/strong&gt;  before you switch branches.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;On my initial days, if this error occurs, I would discard my local changes (to be on the safe side). I should’ve committed it, right? But what if I don’t want to commit my half-done work? Is there a better way?  &lt;strong&gt;What is a stash in git?&lt;/strong&gt;  Let’s explore in this blog about the various usage of &lt;code&gt;git stash&lt;/code&gt;  command.&lt;/p&gt;

&lt;h2&gt;
  
  
  When should you use git-stash?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  CASE 1:
&lt;/h3&gt;

&lt;p&gt;You are in the middle of something, and you have got a call to urgently resolve a bug. (Thanks to your boss). So now you need to switch to a different branch and work on the bug fix. But you have changes you have not committed and you are not yet ready to commit this. What will you do?&lt;/p&gt;

&lt;h3&gt;
  
  
  CASE 2:
&lt;/h3&gt;

&lt;p&gt;You have uncommitted files and try to “git pull” and due to conflicts with the remote changes, git may refuse sometimes to overwrite.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Your local changes to the following files would be overwritten by merge. &lt;strong&gt;Please commit your changes or stash them&lt;/strong&gt;  before you merge.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This same type of error may also occur during a merge request, while pulling the latest changes from the remote branch.&lt;/p&gt;

&lt;p&gt;How will you resolve this scenario?&lt;/p&gt;

&lt;h3&gt;
  
  
  CASE 3:
&lt;/h3&gt;

&lt;p&gt;You had committed to the wrong branch !!! (Seriously, sometimes we make mistakes. Who hasn’t?)&lt;/p&gt;

&lt;p&gt;“&lt;strong&gt;git stash&lt;/strong&gt;” could come for your rescue in most of these cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  So, What is a git stash?
&lt;/h2&gt;

&lt;h4&gt;
  
  
  git stash
&lt;/h4&gt;

&lt;p&gt;According to git-scm documentation,  &lt;strong&gt;git-stash&lt;/strong&gt;  command is used to&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Stash the changes in a dirty working directory away".&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Which means you could throw away your ‘uncommitted changes’ when you don’t want to commit those, in a temporary location (in an intention to take it later). To be precise, your modified ‘tracked’ files and staged changes – will get saved to a ‘stack’ and you can apply these changes later.&lt;/p&gt;

&lt;h4&gt;
  
  
  How to stash changes in git? Now, Let’s git stash - your changes
&lt;/h4&gt;

&lt;p&gt;We can ‘stash’ the changes by simply executing the following command&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git stash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;To read our indepth tutorial on git stash with more examples, please visit - &lt;a href="https://bluecast.tech/blog/git-stash"&gt;https://bluecast.tech/blog/git-stash&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
