DEV Community: Deveesh Shetty The latest articles on DEV Community by Deveesh Shetty (@devshetty). https://dev.to/devshetty 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%2F945414%2Fd0c10ab8-b8d2-473b-9c93-19af1971c010.jpg DEV Community: Deveesh Shetty https://dev.to/devshetty en Breaking down CSS positioning Deveesh Shetty Mon, 15 Sep 2025 18:32:54 +0000 https://dev.to/devshetty/breaking-down-css-positioning-32ah https://dev.to/devshetty/breaking-down-css-positioning-32ah <p>Whomever i talk to about CSS, says they struggle with positions and how they actually work</p> <p>Made a few illustrations to make it little less random when you use them for the next time.</p> <p>By default all the elements in the page are <code>position: static</code>, it means they will follow the usual sequential approach of HTML page</p> <p><a href="proxy.php?url=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%2Fu8hgh7qj6hpg3aj0r7ci.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fu8hgh7qj6hpg3aj0r7ci.png" alt="Elements are static by default" width="471" height="329"></a></p> <p>But sometimes you need to position elements at a different place, or in a different manner. 99% of the times you can get away by using layout properties like <code>flex</code> or <code>grid</code>, but sometimes you need to take matter into your own hands and use <code>position</code> property</p> <h3> position: relative </h3> <p>This is the simplest of them all, when you add this to your css, for your surprise. it does nothing, absolutely nothing by itself</p> <p><a href="proxy.php?url=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%2Frcm5ueyyfui4i59fggfk.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Frcm5ueyyfui4i59fggfk.png" alt="Change all elements to relative position" width="471" height="329"></a></p> <p>But this position value allows you to add properties like top, right, bottom, left and also z-index. This gives you more control on where to keep the element</p> <p><a href="proxy.php?url=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%2Fz2uo4da9pa52a7wb41si.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fz2uo4da9pa52a7wb41si.png" alt="Adding top and left properties to relative element" width="483" height="329"></a></p> <h3> position: absolute </h3> <p>This is little scarier than relative, and sometimes haunts me in my dreams, absolute positioning makes your element fly in the DOM. basically the element exits the sequential flow of the HTML document.</p> <p><a href="proxy.php?url=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%2Ff1j06t3d86bb36yo1yvi.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Ff1j06t3d86bb36yo1yvi.png" alt="Absolute positioning an element" width="471" height="329"></a></p> <p>Absolute element will always be positioned relative to the nearest relative parent.</p> <p>अर्थात् (meaning): If you position an element as absolute it will take the top, right, bottom, left (TRBL) properties based on the nearest parent which is set to position relative. </p> <p>If no parent has position relative, it will fallback to the HTML root, ie the window. That's why you can see it is stuck on the top left of the page.</p> <p><a href="proxy.php?url=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%2Fkskim9cevqkbrxddvt8z.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fkskim9cevqkbrxddvt8z.png" alt="Adding top and left properties to absolute element" width="482" height="329"></a></p> <p>Notice it now it changes relative to the window</p> <p>Now let's enclose it in a parent which has position relative, then it will be positioned with respect to the parents TRBL properties</p> <p><a href="proxy.php?url=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%2Fyup6g5xfyjppzvjrk90i.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fyup6g5xfyjppzvjrk90i.png" alt="Absolute positioning an element inside a relative parent" width="471" height="329"></a></p> <p>Adding some TRBL properties to the absolute element</p> <p><a href="proxy.php?url=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%2Fe42ceo0yjfmd0ie5fcnb.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fe42ceo0yjfmd0ie5fcnb.png" alt="Adding top and left properties to absolute element inside a relative parent" width="471" height="329"></a></p> <p>That's it, it ain't no rocket science. Mess around a little with it and you will be more confident in writing them</p> <p>Also as a side note, try to avoid absolute positioning as much as you can, since it will create more problems then it might solve, ranging from pixel manipulation till responsiveness.</p> <p>Originally posted on <a href="proxy.php?url=https://x.com/ShettyDeveesh/status/1967616343860990233" rel="noopener noreferrer">X</a></p> <p><strong>Deveesh Shetty</strong><br> <a href="proxy.php?url=https://github.com/Deveesh-Shetty" rel="noopener noreferrer">Github</a> | <a href="proxy.php?url=https://x.com/ShettyDeveesh" rel="noopener noreferrer">X</a></p> webdev css Why should I cherry-pick? Deveesh Shetty Mon, 10 Feb 2025 20:56:25 +0000 https://dev.to/devshetty/why-should-i-cherry-pick-3onl https://dev.to/devshetty/why-should-i-cherry-pick-3onl <p>Even I had this question, in my mind it was another feature that I would never use. But well I was wrong, I use it quite often.</p> <p>Let's understand it with a real-case scenario.</p> <h3> Ever accidentally commited to a wrong branch, and wanted to revert? </h3> <p>Well, you could have done it the old fashion way of undoing the commit, changing branch and commiting again. But this will be a mess when you are down multiple commits.</p> <h3> But there is a better way to do it. </h3> <p><strong>Step 1:</strong> Realise you commited in <code>master</code> instead of <code>my-feature</code> branch.</p> <p><strong>Step 2:</strong> Copy the hash of the commits you want in the other branch. Run this where you committed your changes, ie. <code>master</code> branch here.</p> <p>Note: If you need multiple commits, either you can copy all the hashes, or if they are consecutive commits, you only need to copy the first mistaken commit hash and the last commit hash.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git log <span class="nt">--oneline</span> </code></pre> </div> <p><strong>Step 3:</strong> Switch to the <code>my-feature</code> branch<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git checkout my-feature </code></pre> </div> <p>Add <code>-b</code> flag if you are creating a new branch. Read more about branches <a href="proxy.php?url=https://dev.to/devshetty/learn-about-branching-in-git-bm3">here</a>.</p> <p><strong>Step 4:</strong> If you have</p> <ul> <li>(i) One commit </li> </ul> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git cherry-pick &lt;<span class="nb">hash</span><span class="o">&gt;</span> </code></pre> </div> <ul> <li>(ii) Multiple commits </li> </ul> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git cherry-pick &lt;hash1&gt; &lt;hash2&gt; &lt;hash3&gt; </code></pre> </div> <ul> <li>(iii) Consecutive range of commits </li> </ul> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git cherry-pick &lt;first-hash&gt;..&lt;last-hash&gt; </code></pre> </div> <p>Congratulation, you will have those commits in <code>my-feature</code> branch. 🎉</p> <p><strong>Step 5:</strong> (Optional) Delete commits from <code>master</code> branch.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git checkout master git reset <span class="nt">--hard</span> HEAD~N </code></pre> </div> <p>Where N is the number of commits, only do this when the commits are consecutive, and on tip of the branch. This works for our situation.</p> <p>Or you can also use interactive rebase to drop specific commits<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git rebase <span class="nt">-i</span> &lt;commit-hash&gt; </code></pre> </div> <h3> Bonus </h3> <ul> <li>You can use <code>-n</code> flag to apply changes without commiting in the new branch</li> <li>Use <code>-x</code> file to retain reference of the original commit which was cherry-picked. It shows up like this <img src="proxy.php?url=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%2F98xj5wmpg0omgvtqbblx.png" alt="Cherry pick original reference" width="800" height="187"> </li> </ul> <p>That's it. As simple as it is.</p> <p>It has saved me a lot of time when I accidentally commit changes to the main branch or a wrong feature branch (yeah, I don't delete local branches after they are merged);</p> <p>Git cherry-picking can also be used for, selecting specific features from a branch, reordering commits, and much more left to your creativity.</p> <p>Thank you for reading through the blog, its been quite a while (11 months to be exact) since I wrote my last blog. Working on increasing the regularity of blog posts.</p> <p>Deveesh Shetty<br> <a href="proxy.php?url=https://x.com/ShettyDeveesh" rel="noopener noreferrer">Twitter</a> | <a href="proxy.php?url=https://github.com/dev-shetty" rel="noopener noreferrer">GitHub</a></p> <p>Credits:<br> Cover Image - <a href="proxy.php?url=https://unsplash.com/photos/person-holding-red-and-green-fruit-in-green-and-white-basket-uEit-8uQdPU" rel="noopener noreferrer">Unsplash</a></p> git github Javascript History API Deveesh Shetty Sat, 30 Mar 2024 11:22:43 +0000 https://dev.to/devshetty/javascript-history-api-477o https://dev.to/devshetty/javascript-history-api-477o <p><em>This is a submission for DEV Challenge v24.03.20, One Byte Explainer: Browser API or Feature.</em></p> <h2> Explainer </h2> <p>Want to mess with history?</p> <p>Well, you can, at least in JavaScript. Check out the History API, to go front and back the browser page<br> <code>history.forward()</code> - for next page<br> <code>history.back()</code> - for previous page </p> <p>You can try it in the browser console as well.</p> <h2> Additional Context </h2> <p>I recently found it while exploring Web APIs in MDN docs, it is quite handy if you are working with vanilla HTML, and want to go back and forth in browser sessions.</p> <p>Full document - <a href="proxy.php?url=https://developer.mozilla.org/en-US/docs/Web/API/History_API" rel="noopener noreferrer">History API MDN</a></p> <p>Thank you for reading!</p> <p><strong>Deveesh Shetty</strong><br> <a href="proxy.php?url=https://github.com/dev-shetty" rel="noopener noreferrer">Github</a> | <a href="proxy.php?url=https://twitter.com/shettydeveesh" rel="noopener noreferrer">Twitter</a></p> frontendchallenge devchallenge javascript webdev CSS Art: Paneer Tikka Deveesh Shetty Sat, 30 Mar 2024 07:40:20 +0000 https://dev.to/devshetty/css-art-paneer-tikka-3p8d https://dev.to/devshetty/css-art-paneer-tikka-3p8d <p><em>This is a submission for DEV Challenge v24.03.20, CSS Art: Favorite Snack.</em></p> <h2> Inspiration </h2> <p>India is famous for its delicacies, for every 10 kilometers you travel, you will find a new food item that is famous in that area. </p> <p>Being a South Indian, I like North Indian food, despite having a variety of dishes, one of my favorite starters is Paneer Tikka. This starter is made by adding paneer, onion, capsicum, and tomato to a stick and grilling it in a <a href="proxy.php?url=https://en.wikipedia.org/wiki/Tandoor" rel="noopener noreferrer">Tandoor</a> </p> <h2> Demo </h2> <p><iframe height="600" src="proxy.php?url=https://codepen.io/deveesh_shetty_12/embed/GRLMBzE?height=600&amp;default-tab=result&amp;embed-version=2"> </iframe> </p> <h2> Journey </h2> <p>It has been a very long time since I used vanilla CSS, Tailwind CSS totally didn't spoil me XD.</p> <p>Well jokes apart, I woke up with an email from Devto about this challenge, and in no time I started to think about my favorite dish that I could create.</p> <p>It was a fun journey that took almost 3-4 hours to put this up, and the neat part it is 100% responsive. The first time I used the General Sibling Selector (~) in CSS, and also added a fun hover animation to eat the paneer tikka.</p> <p>My step-by-step take on building this ✨</p> <ul> <li><p>First, I created a plate that was quite simple, I used CSS pseudo-elements to give inner borders, and border-radius to have the croissant-type shape.</p></li> <li><p>Then I proceeded to create a stick and centered it on the plate using a Flexbox.</p></li> <li><p>Next comes the food item, I placed each item ie Paneer, Capsicum, etc. in a div with particular class names, and styled them accordingly using CSS colors, borders, and box-shadows.</p></li> <li><p>All the items are child of the stick so it was easy to align them with a simple flex.</p></li> <li><p>Next comes the sauce (literally), firstly I drew 2 circles and masked them with their pseudo-element to have a semi-circular pattern.</p></li> <li><p>Created 2 extra divs and positioned them at the top right as sauce bowls.</p></li> <li><p>Added some final box-shadow which gave some depth effect to the plate and bowls.</p></li> <li><p>Still, something is missing, yes animation! So I added a small hover effect which on hover eats everything in the plate and leaves one capsicum XD</p></li> </ul> <p>If you found it delicious you can find the recipe here - <a href="proxy.php?url=https://www.indianhealthyrecipes.com/paneer-tikka-on-stove-top/" rel="noopener noreferrer">Paneer Tikka Recipe</a></p> <p>Thank you for reading!</p> <p><strong>Deveesh Shetty</strong><br> <a href="proxy.php?url=https://github.com/dev-shetty" rel="noopener noreferrer">Github</a> | <a href="proxy.php?url=https://twitter.com/shettydeveesh" rel="noopener noreferrer">Twitter</a></p> frontendchallenge devchallenge css Finding Issues for Hacktoberfest Deveesh Shetty Mon, 02 Oct 2023 14:45:37 +0000 https://dev.to/devshetty/finding-issues-for-hacktoberfest-1knd https://dev.to/devshetty/finding-issues-for-hacktoberfest-1knd <p>There are millions of open-source projects you can contribute in GitHub,</p> <p>Checkout for the tags like,</p> <p>🔖 good-first-issue: Which means the fix is beginner friendly</p> <p>🔖 hacktoberfest: All the projects/issues accepted for hacktoberfest most of them are quite easy to work with</p> <p>🔖 documentation: open-source is not only about code even documentation counts</p> <p>If you are confused about an issue, you can ask about it in the issue comments, most maintainers are more than ready to help you.</p> beginners github opensource hacktoberfest23 Beyond console.log in JavaScript Deveesh Shetty Tue, 19 Sep 2023 12:09:57 +0000 https://dev.to/devshetty/beyond-consolelog-in-javascript-267f https://dev.to/devshetty/beyond-consolelog-in-javascript-267f <p>You may have only used <code>console.log()</code> in JavaScript, but you can do many more things with the <strong>console</strong> object.</p> <h2> console.table() </h2> <p>If you have an object and want a clear view of it instead of having those ugly braces in the console you can use <code>console.table()</code><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight javascript"><code><span class="kd">const</span> <span class="nx">obj</span> <span class="o">=</span> <span class="p">{</span> <span class="na">name</span><span class="p">:</span> <span class="dl">"</span><span class="s2">John</span><span class="dl">"</span><span class="p">,</span> <span class="na">age</span><span class="p">:</span> <span class="mi">30</span><span class="p">,</span> <span class="na">city</span><span class="p">:</span> <span class="dl">"</span><span class="s2">New York</span><span class="dl">"</span><span class="p">,</span> <span class="na">country</span><span class="p">:</span> <span class="dl">"</span><span class="s2">USA</span><span class="dl">"</span><span class="p">,</span> <span class="p">}</span> <span class="nx">console</span><span class="p">.</span><span class="nf">table</span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> </code></pre> </div> <p><a href="proxy.php?url=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%2F2f45zqqoytph781kyak4.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2F2f45zqqoytph781kyak4.png" alt="console.table output" width="800" height="119"></a></p> <h2> console.error() </h2> <p>You will get a cool-looking (yeah 🙂) red color message for the instances where you want to make the stress on the bug more realistic.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight javascript"><code><span class="nx">console</span><span class="p">.</span><span class="nf">error</span><span class="p">(</span><span class="dl">"</span><span class="s2">Why is this rendering twice</span><span class="dl">"</span><span class="p">)</span> </code></pre> </div> <p><a href="proxy.php?url=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%2Fkc0wuhxl6gvkq0ds3pba.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fkc0wuhxl6gvkq0ds3pba.png" alt="console.error output" width="800" height="111"></a></p> <h2> console.warn() </h2> <p>Similar to error but a little less stressful, you can mostly use this as a warning to yourself.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight javascript"><code><span class="nx">console</span><span class="p">.</span><span class="nf">warn</span><span class="p">(</span><span class="dl">"</span><span class="s2">Fix this in the next release!</span><span class="dl">"</span><span class="p">)</span> </code></pre> </div> <p><a href="proxy.php?url=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%2F1c9en7hutb2nulv0j3ta.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2F1c9en7hutb2nulv0j3ta.png" alt="console.warn output" width="800" height="128"></a></p> <h2> console.time() </h2> <p>You can get the computation time easily by using <code>console.time()</code>, which starts the timer, and <code>console.timeEnd()</code> which ends it to compute the time taken by your code.<br> You can pass a label inside the <code>time()</code> function which makes the timer unique, so you can have as many number of timers in your program.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight javascript"><code><span class="nx">console</span><span class="p">.</span><span class="nf">time</span><span class="p">(</span><span class="dl">"</span><span class="s2">Time</span><span class="dl">"</span><span class="p">)</span> <span class="kd">let</span> <span class="nx">count</span> <span class="o">=</span> <span class="mi">0</span> <span class="k">for </span><span class="p">(</span><span class="kd">let</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="mi">100000</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span> <span class="nx">count</span> <span class="o">+=</span> <span class="mi">1</span> <span class="p">}</span> <span class="nx">console</span><span class="p">.</span><span class="nf">timeEnd</span><span class="p">(</span><span class="dl">"</span><span class="s2">Time</span><span class="dl">"</span><span class="p">)</span> </code></pre> </div> <p><a href="proxy.php?url=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%2Fwb5i47dpx70f88raqaf9.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fwb5i47dpx70f88raqaf9.png" alt="console.time output" width="800" height="85"></a></p> <p>That's it for this blog... There are many more methods available, if you are interested you can check it out at <a href="proxy.php?url=https://developer.mozilla.org/en-US/docs/Web/API/console" rel="noopener noreferrer">MDN Docs</a>.</p> <p><strong>Deveesh Shetty</strong><br> <a href="proxy.php?url=https://github.com/Deveesh-Shetty" rel="noopener noreferrer">Github</a> | <a href="proxy.php?url=https://twitter.com/shettydeveesh" rel="noopener noreferrer">Twitter</a></p> javascript webdev beginners Creating a Pull Request in GitHub Deveesh Shetty Thu, 07 Sep 2023 07:31:49 +0000 https://dev.to/devshetty/guide-to-creating-a-pull-request-in-github-2ef2 https://dev.to/devshetty/guide-to-creating-a-pull-request-in-github-2ef2 <p>In this blog we will be seeing how to contribute to Open Source Projects by creating your very first Pull Request as a beginner, and trust me it is going to be very easy.</p> <p><em>NOTE: I value your time so, if you want to skip to the fun part and avoid theory, click here.</em></p> <p>Before getting started, if you don't know about Git commands, I have covered it in my blog post about <a href="proxy.php?url=https://dev.to/devshetty/git-and-github-for-beginners-the-basics-d3n">Git and GitHub Basics</a></p> <h2> Introduction </h2> <p>To contribute to open-source projects you have to follow a certain steps, you can't directly push a commit to others' repository. For that you have to make the changes in your local (forked) repository then send a Pull Request which has the changes, which when accepted will reflect the changes to the original repository.</p> <p>Didn't understand what I mean? Don't worry, because it was difficult for me too to understand it in the first glance. So let me break it down step by step which will help you understand it much better.</p> <h2> The cycle of contributing </h2> <p><a href="proxy.php?url=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%2Fwvor2gsoz07gzfxj8v9l.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fwvor2gsoz07gzfxj8v9l.png" alt="Sending a PR" width="800" height="487"></a></p> <p><strong>Remote Repository</strong>: The repository (repo) to which you want to contribute to, which is owned and maintained by other person or organisation.</p> <p><strong>Fork</strong>: You are creating a copy of the remote repo to your own GitHub account, where you can do changes without affecting the original (remote) repo. Forked repo can also be called as Local repo.</p> <p><strong>Clone</strong>: You clone the content of the repo from the remote/local repo to your machine, where you can open it in your desired text-editor or IDE.</p> <p><strong>Push</strong>: You are updating (pushing) the changes made in your PC to the repo.</p> <p><strong>Pull</strong>: You are updating the code in your PC by importing (pulling) content from the repo.</p> <p><strong>Pull Request</strong>: The changes you made in the fork are limited to your account, to reflect it in the remote repository you send a Pull Request (PR) to request the author to pull the changes from your local repo to the remote repo. We will be talking about it in detail in upcoming sections.</p> <p>When you want to <code>contribute</code> to a open-source project, </p> <ul> <li>You first <code>fork</code> the repo to your account.</li> <li>Then <code>clone</code> the forked repo onto your PC. </li> <li>Open the cloned folder in your desired text-editor.</li> <li>Create a <code>branch</code> and switch to it.</li> <li>Do the needful changes and <code>add</code> those changes to staging area. </li> <li>Once you are confident with the changes <code>commit</code> it with a good message.</li> <li>Then <code>push</code> it to your local (forked) repo.</li> <li>Once everything is all set, send a <code>Pull Request</code> using the "Compare and Pull Request" button, mention what are the changes and improvement your PR is doing and Create the PR.</li> </ul> <p>Yes as simple as it is!!</p> <p>Next, the maintainers of the open-source repo will review it, if they need any changes they will mention it in comments. If everything goes alright, they will <code>merge</code> the Pull Request. Which means your contribution is live in the remote repo. Congratulations 🥳! </p> <p>That's all theory, the real fun is in hands-on let's dive into it and contribute to an actual repository on GitHub.<br> I will be using <a href="proxy.php?url=https://github.com/Deveesh-Shetty/Commit-to-Success" rel="noopener noreferrer">Commit-to-Success</a> repo, which I created for my Git and GitHub session, here you can add a file about yourself. You are free to contribute to any repo (but, I would love to see your PRs in my repo 😄)</p> <h2> Hands on Contribution </h2> <p>Gather all the knowledge which I mentioned above and let's apply it here!</p> <ul> <li>First let's go to <a href="proxy.php?url=https://github.com/Deveesh-Shetty/Commit-to-Success" rel="noopener noreferrer">Commit-to-Success</a> repository.</li> </ul> <p>You will see a interface like this<br> <a href="proxy.php?url=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%2F18a3x49dnovd7e2wwlkh.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2F18a3x49dnovd7e2wwlkh.png" alt="Commit to Success Repo" width="800" height="371"></a></p> <ul> <li>Next, fork the repo by clicking the <code>Fork</code> button on top-right</li> </ul> <p><a href="proxy.php?url=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%2Fv1dwg31w4bw37u17pkbn.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fv1dwg31w4bw37u17pkbn.png" alt="Fork Button" width="154" height="51"></a></p> <ul> <li>You will be redirected to a page, where you can keep everything as default and press <strong>Create Fork</strong> </li> </ul> <p><a href="proxy.php?url=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%2F0h4x0g4jl5ce436a8kxh.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2F0h4x0g4jl5ce436a8kxh.png" alt="Fork confirmation" width="784" height="506"></a></p> <p><strong>Note:</strong> Choose your GitHub profile in the <strong>Owner</strong> section.</p> <ul> <li>It will take a few seconds, and you will be redirected to your <code>forked</code> repo.</li> </ul> <p><strong>Tip:</strong> You can identify the forked repo by seeing the URL it will be <code>your-username/Commit-to-Success</code>, while that of the remote repo is <code>Deveesh-Shetty/Commit-to-Success</code> </p> <ul> <li>Next, press green color <code>code</code> button in your forked repo and at the top-right and copy the https url given below</li> </ul> <p><a href="proxy.php?url=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%2Ftqg1lkupm0kim69plbj2.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Ftqg1lkupm0kim69plbj2.png" alt="Green color code button to clone" width="428" height="347"></a> <strong>Note:</strong> The URL will be different in your case. </p> <ul> <li>Now, open a terminal in the desired place where you would like to have the folder. It can be D Drive, Desktop, your choice. </li> <li>Next in the terminal type this command to clone the repository: </li> </ul> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git clone &lt;copied-url&gt; </code></pre> </div> <p><strong>Note:</strong> Replace <code>&lt;copied-url&gt;</code> with the url you copied in the previous step, without the brackets <code>&lt;&gt;</code>.</p> <ul> <li><p>It will take a few seconds, and you will see a new folder named <code>Commit-to-Success</code> got created. Now open that folder in your desired text-editor. I will be using VS-Code.</p></li> <li><p>The setup is done! Congratulations on making it till here! Now, Let's get coding (in our case, adding our readme file).</p></li> </ul> <p>It is always a good practice to create a new branch and do the changes there, while working on others' repo. So we will follow it!</p> <ul> <li>Create and switch to a new branch by using this command: </li> </ul> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git checkout <span class="nt">-b</span> &lt;your-name&gt; </code></pre> </div> <p><strong>Note:</strong> Replace with your name, for instance I will name it "deveesh", you are free to name the branch whatever you like! You can learn more about <a href="proxy.php?url=https://dev.to/devshetty/learn-about-branching-in-git-bm3">branching and it's importance</a></p> <ul> <li>Now we are in the <code>deveesh</code> branch, let's create a new file with your name for me it is <code>Deveesh.md</code>.</li> </ul> <p><strong>Note:</strong> <code>md</code> means <a href="proxy.php?url=https://www.markdownguide.org/cheat-sheet/" rel="noopener noreferrer">markdown</a> file.</p> <ul> <li>Add description about yourself in that file, in my case I will add a small description about myself. Be as creative as you want ✨ </li> </ul> <div class="highlight js-code-highlight"> <pre class="highlight markdown"><code><span class="gh"># Deveesh Shetty</span> <span class="p"> -</span> President, SOSC <span class="p">-</span> Passionate Frontend Developer <span class="p">-</span> Open Source enthusiast. <span class="p">-</span> 2nd Year CSE Student at Sahyadri </code></pre> </div> <p>You know the drill next! add, commit and push the changes.</p> <ul> <li>Add the changes </li> </ul> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git add <span class="nb">.</span> </code></pre> </div> <ul> <li>Commit them with a good commit message like </li> </ul> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git commit <span class="nt">-m</span> <span class="s2">"adds deveesh's profile"</span> </code></pre> </div> <ul> <li>Push them to the branch in your local repository, in my case the branch is <code>deveesh</code> </li> </ul> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>git push origin deveesh </code></pre> </div> <p><strong>Note:</strong> Replace deveesh with the branch name which you gave in the previous steps!</p> <ul> <li>Now, If you go back to your forked repo, you will see a alert message like this, in there click <strong>Compare and Pull Request</strong> </li> </ul> <p><a href="proxy.php?url=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%2Fs3q4e1zlgttg70zyexsy.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fs3q4e1zlgttg70zyexsy.png" alt="Compare and Pull Request Alert" width="800" height="127"></a></p> <ul> <li>Now you will be redirected to "Open a Pull Request" page, fill in the title and description of the Pull Request and press <strong>Create a Pull Request</strong> </li> </ul> <p><a href="proxy.php?url=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%2F9a436h3a7sffsra6668w.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2F9a436h3a7sffsra6668w.png" alt="Open a Pull Request Page" width="800" height="419"></a></p> <p>Hurray! You have created your (first) Pull Request. Congratulations 🥳</p> <p>Now, the reviewer (in this case, I) will review the changes and merge the Pull Request to the main remote repository. </p> <p>That is the process of contributing to an open-source project in GitHub. It may seem difficult at beginning, but it becomes easier as you progress. Thank you for sticking till the end and completing the Pull Request! That's it for this blog. Hope to <br> meet you soon, with my another blog 👀</p> <p>If you liked the blog, like and share so more people can benefit from the knowledge. Stuck at a step? Feel free to reach out to me! Also, would love to hear your opinions in comments down below 😄.</p> <p><strong>Deveesh Shetty</strong><br> <a href="proxy.php?url=https://github.com/Deveesh-Shetty" rel="noopener noreferrer">Github</a> | <a href="proxy.php?url=https://twitter.com/shettydeveesh" rel="noopener noreferrer">Twitter</a></p> opensource git github Introduction to GitHub Issues Deveesh Shetty Sat, 19 Aug 2023 09:43:01 +0000 https://dev.to/devshetty/what-are-github-issues-4c3p https://dev.to/devshetty/what-are-github-issues-4c3p <p>You maybe new to GitHub or you are using it from quite a long time. But, have you came across the Issues tab in any GitHub repository? If no, then no worries I will be covering about the Issue tab and how it can make an impact on an open source project.</p> <p><a href="proxy.php?url=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%2Ffobw2gh1v9kaqln89dxg.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Ffobw2gh1v9kaqln89dxg.png" alt="Issue Tab" width="133" height="38"></a><br> You may have seen this tab in GitHub, this is the Issues tab. The number you see next to it are the total issues which are currently Open.</p> <h2> What are GitHub Issues? </h2> <p>Issue is one of the feature by GitHub, it provides a way for the users to track tasks, bug fixes, feature requests, etc.</p> <h2> Why would I use GitHub Issues? </h2> <p>There are endless way for why you will be using the GitHub Issues tab, let me break down a few for you!</p> <h3> Raising a bug report </h3> <p>You are using an open source project, and you were trying something but the result you got was not the one you expected, you will be like (it is some bug in the project) and neglect it... No!! You are a good open source contributor it's your responsibility to let the developer know about the bug, so the best way is if the project is open sourced in GitHub, go to the issue tab and tell about the bug, elaborate on what you wanted and what result you got, provide some visual prove like screenshots or video (if possible). This will help the developer to reproduce the bug and fix it in next release! </p> <h3> Giving idea for a new feature </h3> <p>For instance, you are using a software and you have a very good feature which will improve the software. Why keeping the idea to yourself? Raise a new issue in GitHub and describe your idea in human language (yes, you don't even need to code), and mention how it can improve the project. Now anyone interested can take up the issue and start building the feature, even you can build it if you are interested in it, which is very much appreciated! </p> <p><em>Note: Most of the softwares you use are open source, but you are not aware of it! I can list a few, VSCode, MonkeyType, Python, Android, Linux, Brave Browser and many more... ✨</em> </p> <h2> How to create a new Issue? </h2> <p>If you found a bug, or you have a new feature Idea. Go to the GitHub repository of the project and click the Issues tab. In there click the <code>New Issue</code> button and describe the bug or feature and <code>Submit</code> voila! you have created a new Issue, also you have a green square in your GitHub heatmap 😉.</p> <p><strong>Some Notes:</strong></p> <ul> <li>Before creating an issue make sure there is no similar issue already opened, so it will save your's as well as the maintainer's time.</li> <li>Don't create random issues in repositories, always make sure you have correctly mentioned your plan or described the bug.</li> <li>Use markdown to describe your issue by using todo-lists, heading, code blocks and many more :)</li> </ul> <h3> How to find issues to work as a beginner? </h3> <p>If you are beginner you can find the issues in GitHub repository by filtering with labels like <code>good first issue</code> or <code>first-timers-only</code> or <code>documentation</code> which will help you do your first open source contribution. Most of the repos have these labels which makes it easier for beginners to contribute.</p> <h3> How to work on issues? </h3> <p>Once you found a good issue which you feel like you can work on, put a comment in there that you want to solve it or implement it. So the maintainer can assign you the issue which will make sure no 2 people are working on same issue, which is waste of time for both. Also in contrary, if the issue is already assigned to someone you can't work on it because "Early bird gets the worm". Don't worry try finding another issue there are many...</p> <p>Now you have the issue assigned, <code>fork</code> and <code>clone</code> the repository and create a new <code>branch</code> and start working (don't know what is branching? check it out <a href="proxy.php?url=https://dev.to/devshetty/learn-about-branching-in-git-bm3">here</a>). Once you have a solution for the issue then proceed by creating a <a href="proxy.php?url=https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests" rel="noopener noreferrer"><code>Pull Request</code></a> (PR), now it's maintainers turn to review and merge your PR. If they need any changes do the needful :)</p> <p>I will be covering about Pull Requests in my upcoming blogs stay tuned for that! <br> Thanks for sticking till the end... that's all for this blog, let me know your opinions and suggestions so I can improve my future blogs 😄</p> <p><strong>Deveesh Shetty</strong><br> <a href="proxy.php?url=https://github.com/Deveesh-Shetty" rel="noopener noreferrer">Github</a> | <a href="proxy.php?url=https://twitter.com/shettydeveesh" rel="noopener noreferrer">Twitter</a></p> github git beginners Learn about Branching in Git Deveesh Shetty Mon, 24 Jul 2023 04:29:03 +0000 https://dev.to/devshetty/learn-about-branching-in-git-bm3 https://dev.to/devshetty/learn-about-branching-in-git-bm3 <p>Branching in Git is a very important and one of the core concepts in version control. It is a game-changer, trust me on that :)</p> <h2> What is Branching? </h2> <p>Let's begin with a simple analogy. Imagine yourself as a skilled artist who loves to paint landscapes of nature, Picture yourself sitting in a serene place working on your masterpiece, already half-way through its creation and you encounter a situation where you feel the need to try a new shade for the painting to experiment with colours. Would you risk making the changes directly on the canvas? Of course not! Instead, you would want to freely try out the new colours in a separate piece of paper. If you like the chosen shades, you’ll add it confidently to your actual painting.<br> But, if you weren’t satisfied, then you can simply discard the separate piece of paper and save time to protect the painting from a blunder.</p> <p>So, Branching in Git does the similar thing. If you are working on a project and wish to experiment with new code or implement a new feature, you can simply create a new branch and work on it. If you are satisfied, <code>merge</code> it to the original branch otherwise you can discard it leaving the original code base untouched.</p> <p>I'll show in detail how that works, so stick till the end 😉</p> <h2> Some pre-requisites before we get started </h2> <p>If you don't know about Git or you are new to it, no need to worry. I have covered all the basic concepts of Git in my blog about <a href="proxy.php?url=https://dev.to/devshetty/git-and-github-for-beginners-the-basics-d3n">Git and GitHub - The Basics</a>.</p> <h3> What is a branch? </h3> <p>A branch is a timeline in which you work and commit code changes.</p> <ul> <li> <code>master</code> or <code>main</code> branch is the main timeline in which you'll be working, the changes made to this branch will reflect in production. (Optional) You can rename this branch as well by using: </li> </ul> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git branch <span class="nt">-M</span> &lt;new-name&gt; </code></pre> </div> <ul> <li>Then you can create other branches where you will be implementing features, testing out code, and much more by using the following command: </li> </ul> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git branch &lt;branch-name&gt; </code></pre> </div> <p>Now switch to the new branch by using:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git checkout &lt;branch-name&gt; </code></pre> </div> <p>Replace <code>&lt;branch-name&gt;</code> with a name which reflects the purpose of the branch for eg. <code>feat-dashboard</code> which means I am using this branch to create a new Dashboard Feature.</p> <p><strong>Pro-tip:</strong> You can create a new branch and switch to it in just one command:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git checkout <span class="nt">-b</span> &lt;branch-name&gt; </code></pre> </div> <p>Here, <code>-b</code> flag creates a new branch with the specified name if the branch doesn't already exist.</p> <h3> Let's get started with Hands-on coding </h3> <p>Before continuing with branching commands, ensure that you have some content in the <code>main</code> or <code>master</code> branch, if it is empty, then add a file called <code>Readme.md</code> and add some text in that for instance:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight markdown"><code><span class="gh"># My name is Deveesh Shetty</span> </code></pre> </div> <p>Next, "commit and add" the file by using the following command:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git add <span class="nb">.</span> git commit <span class="nt">-m</span> <span class="s2">"Adds my Readme File"</span> </code></pre> </div> <p>Create a new <code>feature</code> branch and switch into it by running the command:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git checkout <span class="nt">-b</span> feature </code></pre> </div> <p>Now, you are in the <code>feature</code> branch. Add a file in the new branch called <code>Feature.md</code> and open it and add some content in it:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight markdown"><code><span class="gh"># Hello from feature branch</span> </code></pre> </div> <p>You know next, "add and commit" the files by using the following commands:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git add <span class="nb">.</span> git commit <span class="nt">-m</span> <span class="s2">"Adds a Feature File"</span> </code></pre> </div> <p>Check the commit history by running:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git log <span class="nt">--oneline</span> </code></pre> </div> <p>You shall see an output similar to:</p> <p><a href="proxy.php?url=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%2F9w5xtlibjf2dbxssmx0g.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2F9w5xtlibjf2dbxssmx0g.png" alt="Git Log in Feature Branch" width="656" height="125"></a></p> <p>I want you to notice <code>(HEAD -&gt; feature)</code> where <code>HEAD</code> is the current commit on which you are and <code>feature</code> is the branch we are currently working on.</p> <p>Now, try switching back to the <code>master</code> or <code>main</code> branch by using either one of these command based on your main branch name (eg.: if the branch name is <code>main</code> then run <code>git checkout main</code>)<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git checkout main <span class="c"># or</span> git checkout master </code></pre> </div> <p><em>If you encounter an error while running this command, one possible issue might be that you haven't committed the code in the current branch. To resolve this make sure to commit your changes to the current branch and then try the above command again.</em></p> <p>Run the <code>git log --oneline</code> command again, and compare the output.</p> <p><a href="proxy.php?url=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%2Fd2ykc52bon3ongj5ia0g.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fd2ykc52bon3ongj5ia0g.png" alt="Git log in Master or Main Branch" width="646" height="108"></a></p> <p>What do you see? The file <code>Feature.md</code> is missing and the commit from the <code>feature</code> branch is also not there. This is the concept of branching, the changes you made in another branch are not reflected in the main branch. It prevents many problems such as breaking the production or having unnecessary codes or commits, etc.</p> <h3> How to get the changes in the main branch? </h3> <p>Well, now in a real-world scenario, you have built a feature in a branch and it works perfectly. Now, you want to include it in the main branch and deploy it to production. How do you do it? It's simple! You merge it 😄</p> <h4> What in the world is merging? </h4> <p>When you want changes from the feature branch to be reflected in the main branch, you do that by merging the feature branch with the main branch. During the merge, a new commit called a merge commit will be formed which will include the changes made in the feature branch and show them in the main or master branch.</p> <p>To achieve this, first, switch to the <code>main</code> or <code>master</code> branch:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git checkout main <span class="c"># or</span> git checkout master </code></pre> </div> <p>And then use the following command to merge the feature branch into main:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git merge feature </code></pre> </div> <p>Here <code>feature</code> is the name of the branch to be merged.</p> <p>You should see the <code>Feature.md</code> file in the folder now. Next, run the <code>git log --oneline</code> command again and view the commit history.</p> <p><a href="proxy.php?url=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%2F7376fqzeo7e70m8prd1q.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2F7376fqzeo7e70m8prd1q.png" alt="Git Log after merging" width="591" height="134"></a></p> <p>You will see the commit made in the feature branch in the main branch. Also, you will notice <code>(HEAD -&gt; master, feature)</code>, which means the current commit is same for both the <code>master</code> and <code>feature</code> branch. (It maybe <code>main</code> in your case, don't worry it's the same)</p> <p>Now you can switch back to the <code>feature</code> branch and start working on it. Once you are comfortable with the changes, merge them into the main branch. It's as simple as that.</p> <p>This is a visual explaining the branching concept<br> <a href="proxy.php?url=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%2Fhyv57jw2pacigt13uft2.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fhyv57jw2pacigt13uft2.png" alt="Branching concept in a diagram" width="800" height="326"></a></p> <p>That's it for branching in this blog. There are many other concepts like Merge Conflicts, Rebasing, etc. that comes with it, which I will be covering in the future blogs 😄. Also there is an upcoming blog on how to create an Issue and send a Pull Request, and contribute to other repositories 👀.</p> <p>Thank you for sticking till the end! Until then have a great day and happy learning!!!</p> <p><strong>Deveesh Shetty</strong><br> <a href="proxy.php?url=https://github.com/Deveesh-Shetty" rel="noopener noreferrer">Github</a> | <a href="proxy.php?url=https://twitter.com/shettydeveesh" rel="noopener noreferrer">Twitter</a></p> git github beginners devops Git and GitHub for Beginners - The Basics Deveesh Shetty Sun, 16 Jul 2023 08:08:38 +0000 https://dev.to/devshetty/git-and-github-for-beginners-the-basics-d3n https://dev.to/devshetty/git-and-github-for-beginners-the-basics-d3n <p>Git Git Git... Git is all we hear people talking about these days. Now, you want to know what it is, so you are in the right place 😉.</p> <p>In this blog you will learn what Git is, why should you be using Git, and how you can start pushing your code to GitHub using Git. And the good part? you won't be needing any prior knowledge for this.</p> <p>Before we get started, let's see...</p> <h2> A brief Introduction </h2> <p>"Git is a <strong>free and open source distributed version control system</strong> designed to handle everything from small to very large projects with speed and efficiency." ~ Linus Trovalds</p> <p>For instance, you are playing a game, where there are checkpoints, so if you lose in the later stages you start again from the previous checkpoint. That is basically one of the many things that Git can help you with.<br> Apart, from that we can have branches, collaboration, reviews, comments, tracking, etc. don't worry you will be seeing these in the later part of blogs.</p> <h2> Installing Git </h2> <p>Refer to this link to download <a href="proxy.php?url=https://git-scm.com/downloads/" rel="noopener noreferrer">Git</a> ✨</p> <h2> Getting Started with Git </h2> <p>Okay, that is all theory, let's start with the commands that you need to get started 😄</p> <p>Now to check whether your machine has Git installed, run the following command<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git <span class="nt">--version</span> </code></pre> </div> <p>If you are getting a output with some numbers for eg. <code>git version 2.41.0</code> (number may not be the same), then you are all ready to go 🥳.</p> <p>Now you have Git installed in your machine. But, Git doesn't know you. So now, you need to tell your name and email to Git by executing the following commands.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git config <span class="nt">--global</span> user.email <span class="s2">"&lt;your-email&gt;"</span> git config <span class="nt">--global</span> user.name <span class="s2">"&lt;your-name&gt;"</span> </code></pre> </div> <p>eg.:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git config <span class="nt">--global</span> user.email <span class="s2">"[email protected]"</span> git config <span class="nt">--global</span> user.name <span class="s2">"John Doe"</span> </code></pre> </div> <p><strong>P.S. Preferred to put your GitHub Email ID</strong></p> <p>Now to check whether your details are added correctly, execute you should be getting your entered details as the output.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git config <span class="nt">--list</span> </code></pre> </div> <p>If the output is too big scroll down using <code>Arrow-down</code> key there you will find your name and email.</p> <p>Okay, the above commands are only needed for people who newly installed Git and this shall only be executed once.</p> <p>Now, Fasten your seat belts and let's get started with Git Commands 🚀</p> <h2> Basic Git Commands </h2> <ul> <li>First things first, whenever you start a new project, in that folder you have to initialise a local repository. </li> </ul> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git init </code></pre> </div> <p>You should get a message saying <strong>Initialised empty git repository</strong>. And also a new hidden file should be formed called <code>.git</code> which git uses to keep track of that folder.</p> <p>Now the question arises, How do I create a checkpoint and save my code in the Git repository?</p> <p>For that we will be following these three concepts, you can see them in the flow diagram below.</p> <p><a href="proxy.php?url=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%2Fue4u5ql7c3cgxwgs7evy.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fue4u5ql7c3cgxwgs7evy.png" alt="Workflow of Add, Commit and Push" width="800" height="394"></a></p> <p>Let me explain that in detail, when we create a new file, Git doesn't know that there is a new file. So we will be <code>add</code>ing the file to staging area where you can check the files and do any optimisation if needed, and also git can keep a track of it. Then we take a snapshot of all the current files i.e basically creating a checkpoint by <code>commit</code>ing the files. Then if we have connected our local repository with GitHub then we can <code>push</code> it, so everyone can access those files and collaborate, review and comment on it.</p> <p>I know this is quite confusing, but it will get cleared as we move on with each step particularly and seeing how to do that using commands. </p> <h3> Add, Commit and Push our code </h3> <p>These are the commands you will be using most of the times while working on your project.</p> <h4> Adding files to Staging area </h4> <p>In the folder create a new file called as <code>Readme.md</code> and write something inside it for eg.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code># Hello! My Name is Deveesh Shetty </code></pre> </div> <p>P.S. <code>.md</code> means a markdown file which is like a text file but with extra features. Like here <code>#</code> represents <code>&lt;h1&gt;</code> tag from HTML</p> <p>Git doesn't know that you have created a new file, so you can do it by adding the file to the staging area by using the command<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git add &lt;file-name&gt; </code></pre> </div> <p>Here in my case replace the <code>&lt;file-name&gt;</code> with <code>Readme.md</code></p> <p><strong>Pro-tip</strong>: You can replace the file name with <code>.</code> (a period) to add all the untracked and modified files in that folder to the staging area.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git add <span class="nb">.</span> </code></pre> </div> <h4> Removing files from Staging area </h4> <p>Now your files are in the staging area. But you want to remove some files from the staging area which are not ready yet, you can simply do it by using the following command<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git reset &lt;file-name&gt; </code></pre> </div> <h4> Creating a Commit </h4> <p>Commit or in simple terms a checkpoint is where you save the past history of your code like a snapshot, and its very important because you can traverse through your previous code iterations and also get to know when was the particular change done in the code.</p> <p>Once, you have staged all the changes, creating a commit is quite simple by doing<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git commit <span class="nt">-m</span> <span class="s2">"Message describing the changes u made"</span> </code></pre> </div> <p><strong>Pro-tip</strong>: The message you write while committing should give a brief idea about what changes are made while the committing the code. </p> <p>For example in my case it is:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git commit <span class="nt">-m</span> <span class="s2">"Adds Readme File"</span> </code></pre> </div> <p>Now you have created a checkpoint for your code which u can see by running the following command<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git log </code></pre> </div> <p>This command will give you all the commits you made with the <code>Author</code> of the commit, <code>Time</code> when the commit was made, and also a unique ID called <code>Commit Hash</code> with the <code>Commit Message</code>.</p> <p>The logs will be ordered in descending order, meaning the most recent commit will be at the top and you can access the old ones by pressing <code>Arrow-down</code> key. Once you have gone through it, press <code>q</code> to exit the log command.</p> <p>If you just want to see the flow of recent commits with no extra information about author and time, you can use the following command to achieve it.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git log <span class="nt">--oneline</span> </code></pre> </div> <p>Also you may, have noticed something like <code>(HEAD -&gt; master)</code> or <code>(HEAD -&gt; main)</code>. Here <code>HEAD</code> means the current commit in which you are, in our case it is the <strong>most recent commit</strong> and <code>main</code> and <code>master</code> means the default branch name. Don't worry about branches right now, it is covered in the later parts of the blog :) </p> <h4> Honorable mention </h4> <p>You can try using this command after each process where it will tell you what is the current status of the files in your project<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git status </code></pre> </div> <p>or to get everything in brief add the <code>-s</code> flag after it.</p> <p>You will get one or two letters in front of each file-name you can refer this table to know more about it.<br> <a href="proxy.php?url=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%2Fxbhjq0lbhy4kbrt7o8lm.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fxbhjq0lbhy4kbrt7o8lm.png" alt="git status letter meanings" width="622" height="274"></a></p> <h4> Pushing your code </h4> <p>All the things which we did till now is only limited to your PC that's why it is called <code>local repository</code>, no one else can see it. </p> <ul> <li>Now, you are working on a project and you want your friend to help you with that. How can you do it? It's simple you have to <code>push</code> your code to a <code>remote repository</code>, which is basically a folder which is hosted somewhere and it can be access by anyone (U can make it private and limited to few people as well).</li> <li>This is where <strong>GitHub</strong> comes into picture. GitHub is a like a storage space for all your git repositories, where people can view, review, comment and collaborate on your code. </li> </ul> <p><strong>Note:</strong> You can use any other platform instead of GitHub, like GitLab, BitBucket, etc. Here I am using GitHub in this blog</p> <p>Before we move on to pushing our code, we have to get working with a few things</p> <ul> <li>If you don't have a GitHub account, create one by going to <a href="proxy.php?url=https://github.com" rel="noopener noreferrer">GitHub</a> </li> <li>Once you have your account, create a new repository by clicking the <code>+</code> icon on the top-right part of the Navbar.</li> </ul> <p><a href="proxy.php?url=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%2F1mtp64el3thwrtuheml5.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2F1mtp64el3thwrtuheml5.png" alt="Creating a new repository" width="245" height="320"></a></p> <ul> <li>Give a <code>Name</code> to the repository and if you want you can give a <code>Description</code> as well. Then you can choose the visibility for the repository. <code>Public</code> means it everyone can see it and <code>Private</code> means it is only visible to you and if needed you can select people who can see the repo later in the settings.</li> </ul> <p>The page should look something like this -<br> <a href="proxy.php?url=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%2Fu3qhazxg6uc8eztiwrp2.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fu3qhazxg6uc8eztiwrp2.png" alt="Creating a Repository" width="800" height="887"></a></p> <ul> <li>Press the <code>Create repository</code> button</li> </ul> <p>You should be redirected to a <strong>Quick Setup</strong> page, where if you scroll down you can find this code snippet (Don't copy mine as it will be different in your account)</p> <p><a href="proxy.php?url=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%2Fsbatoxwxp3sor3q8uslp.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fsbatoxwxp3sor3q8uslp.png" alt="Setting up remote repository for existing repository" width="800" height="97"></a></p> <p><strong>Note:</strong> We are pushing an existing git repository because we have already created one in previous steps, no need to redo it.</p> <p>You can copy and paste those commands to your terminal and it should <code>push</code> your existing code to your remote repository.</p> <p>But, I won't let you just copy paste, let's see what each command is doing in here<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git remote add origin https://github.com/Deveesh-Shetty/Learn-Git.git </code></pre> </div> <p><strong>In your case the URL will be different</strong><br> What this command does is, it is telling git to add a remote repository named <code>origin</code> and the path of the repository is mentioned in the url</p> <p>You can check your remote repository by running<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git remote <span class="nt">-v</span> </code></pre> </div> <p>It should list the remote repository(s)</p> <p>Next command, this is used to make sure that the branch name in the git repository is same as that of GitHub by renaming the branch name, so there won't be any difficulties in later stage.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git branch <span class="nt">-M</span> master </code></pre> </div> <p><strong>Note:</strong> In your PC the command may have <code>main</code> instead of <code>master</code> it is totally fine, it is based on the branch name which is mentioned in GitHub. So don't change it.<br> Also to note, the above two steps is required only once only while creating a new repository.</p> <p>Finally, we are pushing the code by running<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git push <span class="nt">-u</span> origin master </code></pre> </div> <p>If I break it down it will look like this<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git push <span class="nt">-u</span> &lt;remote-repo-name&gt; &lt;branch-name&gt; </code></pre> </div> <ul> <li><p>We are telling git to push the code to the remote repository which we added ie <code>origin</code> and to the branch called <code>master</code> or in your case it maybe <code>main</code>.</p></li> <li><p>We are using the <code>-u</code> flag so that next time if we only type <code>git push</code> it will remember the previous instructions and push it to <code>origin master</code>.</p></li> </ul> <p>Now, if you go back to the GitHub <strong>Quick Setup</strong> page, and refresh it, Voila! You should see your code there. Now, you can share the GitHub repository link to your friend and show them the projects u made :)</p> <h3> Summarising everything we learned </h3> <p>This is the basic process of how you can add your code to GitHub, and let the world know about your projects. Let me summarise that for you real quick</p> <ul> <li>Whenever you do some changes to your code, <code>add</code> it to the staging area. </li> </ul> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git add <span class="nb">.</span> </code></pre> </div> <ul> <li>Then when everything looks good, and you are ready to save your process as a checkpoint, <code>commit</code> the code. </li> </ul> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git commit <span class="nt">-m</span> <span class="s2">"what-this-commit-adds/improves"</span> </code></pre> </div> <ul> <li>Then once you are confident enough to show to code to others <code>push</code> it to GitHub </li> </ul> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>git push origin &lt;branch-name&gt; </code></pre> </div> <p><code>&lt;branch-name&gt;</code> can be <code>master</code> or <code>main</code></p> <p>So this is how simple Git is, in your next projects start using Git to record your progress and also utilise GitHub to showcase your work and also to work on other cool open source projects.</p> <h3> Next What? </h3> <p>This is the basic commands that you will be using most of the times, but Git is not limited to this there are a lot of things you can do<br> I am planning to release more blogs continuing this topic, which covers concepts like Branching, Pull Requests, How to Contribute to other's repository and much more.</p> <p>Let me know how informative you found this blog, so that seeing your reviews I will feel more enthusiastic and if there are any improvements I can do it as well.</p> <p>Thank you for sticking till the end, see you with another blog 😄.</p> <p><strong>Deveesh Shetty</strong><br> <a href="proxy.php?url=https://github.com/dev-shetty" rel="noopener noreferrer">Github</a> | <a href="proxy.php?url=https://twitter.com/shettydeveesh" rel="noopener noreferrer">Twitter</a></p> git github beginners Contribute to Open Source as a Beginner Deveesh Shetty Sun, 11 Jun 2023 07:52:18 +0000 https://dev.to/devshetty/contribute-to-open-source-as-a-beginner-4gk8 https://dev.to/devshetty/contribute-to-open-source-as-a-beginner-4gk8 <p>Hey, You heard it right! Open source is for everyone and "Every expert was once a beginner". Start by taking small baby steps by contributing to minute changes to small repositories so you build up confidence to work on bigger projects.</p> <p>So, thinking of that I have created a project for everyone to contribute. <a href="proxy.php?url=https://github.com/Deveesh-Shetty/CSS-Is-Fun" rel="noopener noreferrer">CSS-Is-Fun</a> is a collection of different UI Snippets built using HTML, CSS and JavaScript.</p> <h2> Why CSS-Is-Fun? </h2> <p>Well, it is simple you can create either a simple snippet like a counter to an advanced UI like a dashboard. It is open to all the contributions that you can make. With an easy to follow <code>Readme</code> and <code>Contribution</code> guide this will help you to do your first open source contribution.</p> <h2> What Kind of Snippets can i contribute? </h2> <p>Well it is open to you. You can be as creative as you want in your snippets for instance a button which will give a random quote from an API when you press it or a rigged rock paper scissors game 🤫.<br> So its up to your imagination and your creative mind.</p> <p>So for whom are you waiting for? Start building a cool UI Snippet and contribute to the project.</p> <p>Github Repo - <a href="proxy.php?url=https://github.com/Deveesh-Shetty/CSS-Is-Fun" rel="noopener noreferrer">CSS-Is-Fun</a></p> <p>Twitter - <a href="proxy.php?url=https://twitter.com/shettydeveesh" rel="noopener noreferrer">Deveesh Shetty</a> <br> Also, would love if you tag me with the snippet you created :) Also if any queries you can DM me, I will be more than happy to answer it.<br> `<br> Also, if you are still here I have some great ideas to improve the project and need your help in that</p> <ul> <li>Improve the folder structure so that the main page is not cluttered up.</li> <li>Trying to automate the <code>Readme</code> file which gets updated as we add new snippets.</li> <li>Create and host a landing page for the project with all the snippets mentioned in the website with the link to the Creator's Github.</li> </ul> <p>So that is it for the blog post. See you in the flip side. Looking forward to your contribution.</p> <p>Deveesh Shetty</p> beginners opensource css webdev MongoDB Atlas Hackathon 2022 on DEV Deveesh Shetty Wed, 07 Dec 2022 15:41:38 +0000 https://dev.to/devshetty/mongodb-atlas-hackathon-2022-on-dev-1ni9 https://dev.to/devshetty/mongodb-atlas-hackathon-2022-on-dev-1ni9 <h2> What I Built </h2> <p>Everyone wants to save money but some struggle with it. Your current savings is your future income. So what could be better than tracking all your expenditures and earnings using an expense Tracker.</p> <p>So I created an expense tracker using</p> <ul> <li>ReactJs with ViteJs</li> <li>NodeJs</li> <li>ExpressJS</li> <li>MongoDB</li> <li>Tailwind CSS</li> </ul> <h3> Category Submission: </h3> <p><strong>Choose Your Own Adventure</strong></p> <h3> App Link: </h3> <p>Not deployed yet but will deploy it soon</p> <h3> Screenshots </h3> <p><strong>Initial Page</strong></p> <p><a href="proxy.php?url=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%2Fh5tu8zzlsf3u7ekj62bw.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fh5tu8zzlsf3u7ekj62bw.png" alt="Initial Page" width="800" height="390"></a></p> <p><strong>Adding new expenses / earning</strong></p> <p><a href="proxy.php?url=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%2Fh3xdczkj3ipewt9n5fs5.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fh3xdczkj3ipewt9n5fs5.png" alt="Adding new expenses / earning" width="800" height="390"></a></p> <p><strong>List of all transactions till last one</strong></p> <p><a href="proxy.php?url=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%2Fso8jw0ikhsypfjovvleb.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fso8jw0ikhsypfjovvleb.png" alt="List of all transactions till last one" width="800" height="390"></a></p> <p><strong>Stock Page</strong><br> <a href="proxy.php?url=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%2Fbtc0fic7e6k64qe7pji8.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fbtc0fic7e6k64qe7pji8.png" alt="Stock Page" width="800" height="390"></a></p> <p><strong>Adding New Stocks same goes with updating</strong><br> <a href="proxy.php?url=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%2Fhbyrfkh0jtouu48d2o81.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2Fhbyrfkh0jtouu48d2o81.png" alt="Adding New Stocks" width="800" height="390"></a></p> <p><strong>Mobile view (iPhone 5/SE)</strong></p> <p><a href="proxy.php?url=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%2F5d9lfy5nj6bg8r4ttzoj.png" class="article-body-image-wrapper"><img src="proxy.php?url=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%2F5d9lfy5nj6bg8r4ttzoj.png" alt="Mobile view (iPhone 5/SE)" width="640" height="1136"></a></p> <h3> Description: </h3> <p>My project is an expense tracker for your expenditures. You can add your earning and expenditure with the source (where it was earned / spent) in the space provided and on updating the current balance will be shown with history of last 3 transactions and the balance at that moment of time. And also on click it shows all the transactions made up to the last transaction in the modal<br> It uses ReactJs and TailwindCSS for frontend and it is responsive. Also ExpressJs for backend and of course MongoDB Atlas as Database.</p> <p>P.S. My exams had started in middle on top of that also had some projects, so wasn't able to fully complete it, I had many features in my mind which I will add as I get time.</p> <p>Future Plans:</p> <ul> <li><p>Add stocks page where user can add all their stock holdings and get total holdings and if possible use stocks API (if I find one) to get real time stock data. <strong></strong></p></li> <li><p>Find a way such that the expense will be auto updated whenever there is a message by the bank of debit or credit. Will save users time (Not sure if it is possible in Web)</p></li> </ul> <h3> Link to Source Code: </h3> <p><a href="proxy.php?url=https://github.com/Deveesh-Shetty/Expense-Tracker" rel="noopener noreferrer">https://github.com/Deveesh-Shetty/Expense-Tracker</a></p> <h3> Permissive License: </h3> <p><strong>MIT</strong></p> <h2> Background </h2> <p>I saw many people and also myself struggling to keep track where we spent our money. So keeping a track of it will avoid all these confusions.</p> <h3> How I built it </h3> <p>I used MERN stack to build it and actually, it is my second time (the first time was Traversy Media's tutorial) using MongoDB for an full stack application. And yeah the new thing I learned was backend development and I am loving it. Will do more projects keep participating in Hackathons like this and build my skills 🔥🔥.</p> <h3> Additional Resources/Info </h3> <p>YouTube and Dev.to - That's where I learned everything without spending a single rupee</p> opensource github ai llm