<?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: Manojlo Ilic</title>
    <description>The latest articles on DEV Community by Manojlo Ilic (@milic128).</description>
    <link>https://dev.to/milic128</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%2F1377968%2Fc291e757-31b4-4698-b5d7-ceeb770be6e4.png</url>
      <title>DEV Community: Manojlo Ilic</title>
      <link>https://dev.to/milic128</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/milic128"/>
    <language>en</language>
    <item>
      <title>Git basics</title>
      <dc:creator>Manojlo Ilic</dc:creator>
      <pubDate>Sun, 10 Nov 2024 21:42:44 +0000</pubDate>
      <link>https://dev.to/milic128/git-basics-5g9f</link>
      <guid>https://dev.to/milic128/git-basics-5g9f</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbi0iziq6fkn9z94nw9l2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbi0iziq6fkn9z94nw9l2.png" alt="Git basics" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What is git?
&lt;/h3&gt;

&lt;p&gt;Undoubtedly Git is the most used version control system today. It was developed by Linus Torvalds in 2005 for the development of the Linux kernel.&lt;/p&gt;

&lt;p&gt;Version control system actually means that it simplifies for us developers to track, see changes to our files, and go back in time if something goes wrong.&lt;/p&gt;

&lt;p&gt;An important thing to know is that Git is not some intimidating tool made exclusively for developers. Essentially, you can use it in simple activities such as writing a blog to track and observe your changes. To further expand our understanding of Git, let's use the example of a team of writers. So now imagine a situation where multiple writers want to collaborate on a specific project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjelkugtki68lj6u4o3ou.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjelkugtki68lj6u4o3ou.png" alt="Git community" width="512" height="201"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;They would need a way to track changes to determine who wrote each part and integrate their individual stories into the main one. All of this can essentially simplify the progress of the entire project. After some work by our imagined writers, we could observe their workflow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7hjbj3jkunympw55reu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7hjbj3jkunympw55reu.png" alt="Git Uml" width="512" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can observe the green bullet, which represents the default branch (usually named master or main) that Git creates when you first set up a repository. Writers then create branches from the master and incorporate their changes, which are eventually merged back into the master. I will provide additional explanations on how this is done, along with the commands used.&lt;/p&gt;

&lt;h3&gt;
  
  
  States of Git
&lt;/h3&gt;

&lt;p&gt;One of the primary functions of Git commands is to manipulate data. There are three areas where our data can reside when working with Git.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Modified&lt;/li&gt;
&lt;li&gt;Staged&lt;/li&gt;
&lt;li&gt;Committed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;"Modified" indicates that you have made changes to a file but have not committed them yet.&lt;/p&gt;

&lt;p&gt;"Staged" means you have marked a modified file in its current version to be included in your next commit.&lt;/p&gt;

&lt;p&gt;"Committed" means that the changes are securely stored locally on your machine.&lt;/p&gt;

&lt;p&gt;All these states occur in the local repository. When we push our committed changes, they are transferred to the remote repository. The local directory, as the name suggests, is on our local machine, while the remote repository is situated in the cloud (GitHub, Bitbucket, etc.).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpcbtot5chn3ezwe2lr50.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpcbtot5chn3ezwe2lr50.png" alt="Git stages" width="512" height="274"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Basic Git commands
&lt;/h3&gt;

&lt;p&gt;To initialize a repository, we use git init. This command creates a folder. If you don't see it immediately in your folder path, it might be hidden in Windows. You can reveal it by selecting the option to show hidden files, and then you will be able to see the .git folder.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fub8my4gtp2wourk8yu6y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fub8my4gtp2wourk8yu6y.png" alt="Git init" width="320" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy9dugf9f6l7yki8iuv39.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy9dugf9f6l7yki8iuv39.png" alt="Git folder" width="331" height="52"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After initialization, to move from "modified" to "staged," we use the git add command. To transition from "staged" to "committed," we use the git commit command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F20sxs1eti67rg21m7osx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F20sxs1eti67rg21m7osx.png" alt="Git commands" width="512" height="357"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we reach the "committed" stage, we can proceed to push committed changes to the remote repository using the git push command.&lt;/p&gt;

&lt;p&gt;If we want to retrieve data from a remote repository, we will use the git pull command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcggcke7egq4x7onr7kad.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcggcke7egq4x7onr7kad.png" alt="Git push pull" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So let’s go through all commands at once when pushing new changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;init&lt;/span&gt;
&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="c1"&gt;// add your changes&lt;/span&gt;
&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;commit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;m&lt;/span&gt; &lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="nx"&gt;commit&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt; &lt;span class="c1"&gt;// commit changes with message&lt;/span&gt;
&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;push&lt;/span&gt; &lt;span class="nx"&gt;origin&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;branch&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="c1"&gt;// push to remote repo&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create remote repository
&lt;/h3&gt;

&lt;p&gt;Currently, one of the popular web-based version control platforms is GitHub. Let's dive into it by creating your first repository and committing your changes on GitHub.&lt;/p&gt;

&lt;p&gt;Once you log into your GitHub account, you can find a button to create a new repository.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6lbu8gdb78xz0iojuq3s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6lbu8gdb78xz0iojuq3s.png" alt="Git github" width="426" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After clicking the "New" button, you will see the following options&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl5lnxzrn1xx32nw53xfd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl5lnxzrn1xx32nw53xfd.png" alt="Git github repo" width="800" height="680"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you can start by choosing a &lt;strong&gt;descriptive name&lt;/strong&gt; for your repository. In the description field, you can provide, for example, information about the technologies used in the repository. If it's a public repository, including relevant keywords in the description can make it easier for others to discover.&lt;/p&gt;

&lt;p&gt;The next option allows you to choose whether your repository will be &lt;strong&gt;Public or Private&lt;/strong&gt;. If it's private, only you and your team or organization can access the source code. If it's public, anyone can view, clone, or fork the repository.&lt;/p&gt;

&lt;p&gt;Following that, there's an option to initialize the &lt;strong&gt;readme file&lt;/strong&gt;. You can choose to add it or ignore it at this stage; it doesn't make a significant difference.&lt;/p&gt;

&lt;p&gt;Finally, there's an option to select a &lt;strong&gt;license&lt;/strong&gt;. This informs others about what they can do with your code. Common licenses include the MIT License, which permits the use, copying, modification, merging, publishing, distribution, sublicensing, and selling of copies of your software. You can choose to skip this part if you prefer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjqx24qv72d0ja5uxlxad.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjqx24qv72d0ja5uxlxad.png" alt="Git repo" width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, after selecting all the desired options, we can proceed to create the repository, and we will see the following.&lt;/p&gt;

&lt;p&gt;This is the next page. Now, we can use your Git commands to push to the remote repository. GitHub also provides a suggestion on how to push the first commit.&lt;/p&gt;

&lt;p&gt;You can use any terminal to run Git commands. It can be Git Bash, CMD if you are on Windows, or you can run commands in the Visual Studio Code terminal. Choose the terminal that you are comfortable with for running your Git commands.&lt;/p&gt;

&lt;p&gt;First, navigate to your repository path in Windows. You can do this by holding Shift and right-clicking the file or folder. Then, select "Copy as Path." Alternatively, you can press ALT + D in your current folder and copy the selected text.&lt;/p&gt;

&lt;p&gt;Then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;init&lt;/span&gt;

&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;

&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;commit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;m&lt;/span&gt; &lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="nx"&gt;initial&lt;/span&gt; &lt;span class="nx"&gt;commit&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="/blog/git-basics/git6.png" class="article-body-image-wrapper"&gt;&lt;img src="/blog/git-basics/git6.png" alt="git basics"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;remote&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="nx"&gt;origin&lt;/span&gt; &lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="nx"&gt;your&lt;/span&gt; &lt;span class="nx"&gt;repo&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt; &lt;span class="c1"&gt;//Copy SSH&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;And last thing is to push&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
 &lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;push&lt;/span&gt; &lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="nx"&gt;origin&lt;/span&gt; &lt;span class="nx"&gt;master&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;That's it you now have your code on a remote repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  Git rebase
&lt;/h3&gt;

&lt;p&gt;Git rebase is a command in Git that allows you to rewrite the commit history of a branch by incorporating changes from another branch.&lt;/p&gt;

&lt;p&gt;In other words rebase means moving your branch's starting point to a different commit. It's like pretending you began your work from that new point.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;rebase&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;most of time will be :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;rebase&lt;/span&gt; &lt;span class="nx"&gt;master&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this command you can see visually&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg0spccjtknn4dk69ws2o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg0spccjtknn4dk69ws2o.png" alt="Git rebase" width="800" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Example of git rebase usage&lt;/p&gt;

&lt;p&gt;Main question is why do people use Git rebase?&lt;br&gt;
And the answer is simply to maintain a linear project history.&lt;/p&gt;

&lt;p&gt;Which is good starting point to mention dangers of rebase&lt;/p&gt;
&lt;h4&gt;
  
  
  Dangers of rebase
&lt;/h4&gt;

&lt;p&gt;Imagine a project with two branches: "feature" and "master." The "feature" branch was created from main and depends on a package that was in the meantime taken out from the "master" branch. When you attempt to sync the "feature" branch with the latest "master," the initial modification you made will create a problem, causing errors in the project's build.&lt;/p&gt;

&lt;p&gt;Handling conflicts in the midst of rebasing a long sequence of commits can be perplexing and challenging. It introduces complexity, making it harder to ensure everything is resolved correctly, and it becomes another potential source of errors in the process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@fredrikmorken/why-you-should-stop-using-git-rebase-5552bee4fed1" rel="noopener noreferrer"&gt;From blog&lt;/a&gt; by Fredrik V. Mørken&lt;/p&gt;

&lt;p&gt;There is good observation of this problem which is:&lt;/p&gt;

&lt;p&gt;“I’ve come to the conclusion that it’s about vanity. Rebasing is a purely aesthetic operation. The apparently clean history appeals to us as developers, but it can’t be justified, from a technical nor functional standpoint.”&lt;/p&gt;
&lt;h3&gt;
  
  
  Git merge
&lt;/h3&gt;

&lt;p&gt;Git merge is combining changes from one branch into another. Typically, you'd merge code from a feature branch into the main branch (or master). It's a way to blend the separate work histories, making sure the latest updates from a feature are included in the main project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0te9ny0ce9fysjumf6ur.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0te9ny0ce9fysjumf6ur.png" alt="Git merge" width="512" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Example of merging after some changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;// Start a new feature
git checkout -b new-feature
//Edit some files
&lt;/span&gt;&lt;span class="gp"&gt;git add &amp;lt;file&amp;gt;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="go"&gt;git commit -m "Start a feature"
// Edit additional files
&lt;/span&gt;&lt;span class="gp"&gt;git add &amp;lt;file&amp;gt;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="go"&gt;git commit -m "Finish a feature"
// Merge in the new-feature branch
git checkout main
git merge new-feature

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In team collaboration, we often use platforms (like GitHub) for code management. The typical workflow involves committing your changes locally, pushing your new branch to the remote repository, and then opening a pull request or merge request. Afterward, team members review your commits, ensuring everything is in order. If everything checks out, they merge your changes into the main branch. This process ensures a collaborative and organized approach to integrating new features or fixes into the project.&lt;/p&gt;

&lt;h4&gt;
  
  
  Merge conflicts
&lt;/h4&gt;

&lt;p&gt;The inevitable aspect of Git merges is encountering conflicts.&lt;/p&gt;

&lt;p&gt;Let's explain Git conflicts through an example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyaqvf8tyd2eq9ily047o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyaqvf8tyd2eq9ily047o.png" alt="Git conflict" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Consider a scenario where there exists a file named test.js in the main branch of a project. Now, envision two developers who have been independently working on different branches within the same project. Each developer has made changes to the test.js file on their branches. Developer A successfully merges their changes into the main branch. Then, Developer B attempts to merge their modifications into the main branch as well. Consequently, Git detects conflicting changes and creates a merge conflict in the test.js file. Now Developer B must resolve conflicts to merge their branch successfully. Typically, this involves using some IDE that provides visual tools to identify and resolve conflicts effectively.&lt;/p&gt;

&lt;p&gt;!&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffukc77pzrayog3txq5j5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffukc77pzrayog3txq5j5.png" alt="Vs code git" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Git can also automatically merge changes when the commits occur on separate lines or branches.&lt;/p&gt;

&lt;h3&gt;
  
  
  In Conclusion
&lt;/h3&gt;

&lt;p&gt;We've covered the basic usage of Git, but it's important to note that Git offers a wealth of additional features and functionalities that go well beyond what was explained here so far.&lt;/p&gt;

</description>
      <category>git</category>
      <category>beginners</category>
      <category>learning</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Expo APK build with Windows</title>
      <dc:creator>Manojlo Ilic</dc:creator>
      <pubDate>Wed, 27 Mar 2024 18:06:45 +0000</pubDate>
      <link>https://dev.to/milic128/expo-build-with-windows-10n2</link>
      <guid>https://dev.to/milic128/expo-build-with-windows-10n2</guid>
      <description>&lt;p&gt;I was inspired to write this short blog by not having clear docs on running local builds for expo on Windows OS. So in order to save somebody time and suffering, here are up to date instructions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Expo
&lt;/h2&gt;

&lt;p&gt;Expo is a great framework and platform to get started up to track with React native app development. One of the advantages of expo is the simplified building of the app, also you don't need to spend time configuring it by yourself and if you use the expo cloud you don't need to have MAC to build iOS apps.&lt;/p&gt;

&lt;p&gt;The disadvantage of building an app using the expo server is that it is limited for free usage, so builds may take longer and you have a limited amount of builds per month.&lt;/p&gt;

&lt;p&gt;Logically you will go with the option for &lt;strong&gt;local build&lt;/strong&gt; but then the problem you might have is when you want to build the app, and you have Windows OS.&lt;/p&gt;

&lt;p&gt;If you read the expo docs you will find a simple command to start building the app locally.&lt;/p&gt;

&lt;p&gt;Which goes by &lt;code&gt;eas build --platform android --local&lt;/code&gt; and when you run it from your source code path&lt;/p&gt;

&lt;p&gt;You get an error: &lt;strong&gt;Error: Unsupported platform, macOS or Linux is required to build apps for Android.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now after some research, you may end up like me seeing many problems with expo and building apps locally with Windows.&lt;/p&gt;

&lt;p&gt;Immediate thought is let's just leave the expo and start with react native cli, but nothing is lost yet.&lt;/p&gt;

&lt;p&gt;There is a nice solution for building expo from Windows which is Windows Subsystem for Linux (WSL). So no need to install Linux on a virtual machine to be able to create builds.&lt;/p&gt;

&lt;h2&gt;
  
  
  WSL installation
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1.  Method by terminal&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Open start on Windows and search for Command Prompt&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run command:&lt;br&gt;
&lt;code&gt;wsl --install&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Restart your PC&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run the command to see the list of all WSL distros with command:&lt;br&gt;
&lt;code&gt;wsl --list --online&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyaxjfx24u02zbbpfhb9g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyaxjfx24u02zbbpfhb9g.png" alt="Wsl list"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For this case, you can go with Ubuntu:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Run command :
&lt;code&gt;wsl --install -d Ubuntu&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpeplnntp3n1bwwg2cnmt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpeplnntp3n1bwwg2cnmt.png" alt="Wsl Ubuntu"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You will be prompted to create Unix user, so add your name and password&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After that, you are ready to use it&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Method Install WSL from Microsoft Store&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First is needed to Enable Virtual Machine Platform on you machine. To do that type in search on your windows machine “Turn Windows features on off”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx312b8sdqjhqjtoroc0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx312b8sdqjhqjtoroc0g.png" alt="Enable Virtual Machine"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After clicking on Turn Windows features on off you will see&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgla160rxvpc766foq0vs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgla160rxvpc766foq0vs.png" alt="Enable Virtual Machine"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;And then select Virtual Machine Platform&lt;br&gt;
Click OK&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then you will be prompted to restart the PC, to finish adding changes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open Microsoft Store(from search bar or from pressing start)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search Windows Subsystem for Linux&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install it&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2iokwc9qtew9qu0ynk6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2iokwc9qtew9qu0ynk6.png" alt="Wsl Microsoft store"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also check &lt;a href="https://learn.microsoft.com/en-us/windows/wsl/install" rel="noopener noreferrer"&gt;Official Windows docs to install wsl &lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Necessary tools
&lt;/h2&gt;

&lt;p&gt;Now open your installed WSL Ubuntu terminal&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can do it by running cmd and then selecting installed Ubuntu&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F81e4r0er05r3r78e4qqe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F81e4r0er05r3r78e4qqe.png" alt="Ubuntu terminal"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Or&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run it from Windows search by simply searching for Ubuntu&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Or you can: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run it from VS code terminal where you will be already in the path of your project&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv3a0akj1fjap7jqf0i49.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv3a0akj1fjap7jqf0i49.png" alt="Ubuntu terminal VS code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once we have prepared the WSL Ubuntu terminal and got to the path of our project we can start installing all the neccessary tools&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install OpenJDK you can set the version that you want, in my case I used version 17:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;sudo apt install openjdk-17-jdk-headless gradle&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;set path to JAVA_HOME&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Android command-line tools:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

cd ~
curl https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip -o /tmp/cmd-tools.zip
mkdir -p android/cmdline-tools
unzip -q -d android/cmdline-tools /tmp/cmd-tools.zip
mv android/cmdline-tools/cmdline-tools android/cmdline-tools/latest
rm /tmp/cmd-tools.zip


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

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Set correct path for variables:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

export ANDROID_HOME=$HOME/android
export ANDROID_SDK_ROOT=${ANDROID_HOME}
export PATH=${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${PATH}



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

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Accepting SDK licenses:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;yes | sdkmanager --licenses&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Installing SDK components (set correct android versions):&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Find a version of SDK in your project in &lt;strong&gt;android/build.gradle&lt;/strong&gt; then see &lt;strong&gt;targetSdkVersion&lt;/strong&gt; and &lt;strong&gt;buildToolsVersion&lt;/strong&gt; &lt;br&gt;
Then Install that specific version in my case :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sdkmanager --update&lt;br&gt;
sdkmanager "platforms;android-33" "build-tools;33.0.0"&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Run local build for expo
&lt;/h2&gt;

&lt;p&gt;From &lt;a href="https://docs.expo.dev/build-reference/local-builds/" rel="noopener noreferrer"&gt;expo docs&lt;/a&gt; you can see commands for local build:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;eas build --platform android --local&lt;br&gt;
eas build --platform ios --local&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now run them from the WSL Ubuntu terminal and get your build!&lt;/p&gt;

&lt;p&gt;Note one error that was happening to me multiple times when opening a new WSL terminal is that ANDROID_HOME could not be found, then JAVA_HOME was not found or SDK path was not found. Even though I have run commands and set the correct path already. So what needed to be done to resolve this error was to just run commands again and then it all worked.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>expo</category>
      <category>tutorial</category>
      <category>mobile</category>
    </item>
  </channel>
</rss>
