<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Anas Bouzanbil on Medium]]></title>
        <description><![CDATA[Stories by Anas Bouzanbil on Medium]]></description>
        <link>https://medium.com/@Elhazin?source=rss-d926e523a62b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hJ4k3ohbO3gAjATk8Qxcxw.png</url>
            <title>Stories by Anas Bouzanbil on Medium</title>
            <link>https://medium.com/@Elhazin?source=rss-d926e523a62b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 13 Nov 2026 23:02:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Elhazin/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Understanding the Basics: Authentication vs. Authorization]]></title>
            <link>https://medium.com/@Elhazin/understanding-the-basics-authentication-vs-authorization-292969e71465?source=rss-d926e523a62b------2</link>
            <guid isPermaLink="false">https://medium.com/p/292969e71465</guid>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[toke]]></category>
            <category><![CDATA[https]]></category>
            <dc:creator><![CDATA[Anas Bouzanbil]]></dc:creator>
            <pubDate>Mon, 26 Aug 2024 11:43:30 GMT</pubDate>
            <atom:updated>2024-08-26T11:43:30.442Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rzt-hLMxh3w9y9ty76CSqQ.png" /></figure><p>As a beginner, I often heard the terms <strong>authentication</strong> and <strong>authorization</strong>, but I never really thought about what they meant or how they worked. I implemented several authentication programs and sent tokens for authorization without fully understanding what I was doing — I was just following the steps. However, hearing these terms repeatedly made me curious about their meanings and the differences between them.</p><p>Let’s explain the basic differences in simple terms:</p><p><strong>Authentication</strong> is the process of identifying who you are. When you connect to a server, the server doesn’t know who you are, even if you’re already registered. To identify yourself, the server usually asks you to log in by sending your username or email and password. This process of verifying your identity is called authentication.</p><p>Once authenticated, you might want to perform another action, like sending a request to access a resource. This request is typically made using HTTPS. However, the server still doesn’t recognize you without further identification — it sees you as just another random client. To avoid having to log in again each time you make a request, the server provides a <strong>token</strong> after your initial login. This token acts as a “proof” of your identity and is stored in your browser’s cookies or local storage. Whenever you send a request, the token is sent along with it, allowing the server to recognize and authenticate you without requiring you to log in again.</p><p>In summary, authentication is about proving your identity, while tokens are used to maintain that identity across multiple requests.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=292969e71465" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[literally New To Java?]]></title>
            <link>https://medium.com/@Elhazin/literally-new-to-java-c0b6507f8d04?source=rss-d926e523a62b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0b6507f8d04</guid>
            <category><![CDATA[main-method]]></category>
            <category><![CDATA[jdk]]></category>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[javac]]></category>
            <dc:creator><![CDATA[Anas Bouzanbil]]></dc:creator>
            <pubDate>Fri, 03 May 2024 10:59:36 GMT</pubDate>
            <atom:updated>2024-05-03T11:05:17.482Z</atom:updated>
            <content:encoded><![CDATA[<p>Rayan: Hey, I just learned Java, and it is very cool! do you Want me to show you how to write your first Java program?</p><p>Amine: Yeah, Sure, what’s the program about?</p><p>Rayan: I will keep it simple and I will write a program that says “Hello World” on the screen.</p><p>Amine: It sounds good, let us start!</p><p>Rayan: First, I have to say that Java is all about objects. This means everything in Java is treated like an object. Let me show you the code. The first step is to create a file with the “.java” extension. In this file, we’ll make a class. It’s best to name the class the same as the file name</p><pre>class helloworld{<br><br>}</pre><p>Amine: Alright, we have a file named “helloworld.java” with a class named “helloworld” inside. What’s next?</p><p>Rayan: Okay, next, we’ll try to compile this file and see what happens.</p><pre>javac helloworld.java</pre><p>Amine: What does this command do?</p><p>Rayan: This command compiles the Java file. It reads our code and translates it into a language that the computer can understand. When we run this command, we get a new file named “helloworld.class,” which is the compiled version of our code. It runs on the Java Virtual Machine (JVM), but I’ll explain more about that later.</p><p>Amine: Alright, what do we do after compiling the code? How do we run it?</p><p>Rayan: To run the code, we use the following command:</p><pre>java helloworld</pre><p>Amine: Let’s see what we get on the screen.</p><pre>Error: Main method not found in class helloworld, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application</pre><p>ok we got this because we did not define the main method in our code the main method is the entry point of our program.</p><pre>class helloworld{<br>    public static void main(String[] args){<br>        System.out.println(&quot;Hello World&quot;);<br>    }<br>}</pre><p>Amine: Okay, let’s compile the code and run it.</p><p>Rayan: Well, we got the output “Hello World” on the screen.</p><p>Amine: Hmm, what if I want to add another function to the code?</p><p>Rayan: You can add as many functions as you want, but you have to call them from the main method.</p><p>Amine: Okay, let’s add another function to the code.</p><pre>class helloworld{<br>    public static void main(String[] args){<br>        System.out.println(&quot;Hello World&quot;);<br>        print();<br>    }<br>  <br>    public static void print(){<br>        System.out.println(&quot;This is a new function&quot;);<br>    }<br>}</pre><p>Rayan: And we got this output:</p><pre>Hello World<br>This is a new function</pre><p>Amine: Okay, I got it now. But what do the “public” and “static” keywords mean?</p><p>Rayan: The “public” keyword is an access modifier that allows the main method to be called from outside the class, and the “static” keyword allows the main method to be called without creating an object of the class.</p><p>Amine: Hmm, well, what if I want to add another class to the code and call it from the main method?</p><p>Rayan: You can add as many classes as you want, but you have to call them from the main method.</p><p>Amine: Okay, can you do it?</p><p>Rayan: Sure, let’s add another class to the code.</p><pre>class helloworld{<br>    public static void main(String[] args){<br>        System.out.println(&quot;Hello World&quot;);<br>        print();<br>        newclass obj = new newclass();<br>        obj.print();<br>    }<br>  <br>    public static void print(){<br>        System.out.println(&quot;This is a new function&quot;);<br>    }<br>}<br><br>class newclass{<br>    public void print(){<br>        System.out.println(&quot;This is a new class&quot;);<br>    }<br>}</pre><p>Amine: Okay, I get the idea now. I have a basic idea of how to write a Java program and start working with it. Thank you, Rayan.</p><p>Rayan: You’re welcome, Amine. I’m happy to help you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0b6507f8d04" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Fun and Interactive Discord Bot with Python and JavaScript (Self Bot)]]></title>
            <link>https://medium.com/@Elhazin/building-a-fun-and-interactive-discord-bot-with-python-and-javascript-self-bot-05e1ee9d5ded?source=rss-d926e523a62b------2</link>
            <guid isPermaLink="false">https://medium.com/p/05e1ee9d5ded</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[discord]]></category>
            <category><![CDATA[bots]]></category>
            <category><![CDATA[discord-bot]]></category>
            <dc:creator><![CDATA[Anas Bouzanbil]]></dc:creator>
            <pubDate>Tue, 05 Mar 2024 14:14:42 GMT</pubDate>
            <atom:updated>2024-03-05T14:14:42.316Z</atom:updated>
            <content:encoded><![CDATA[<p>Creating a Discord bot using Python is a fun and easy task. I use it to send multiple messages to my friends, and it can help make your server more engaging and interactive if you’re a server owner.</p><p>Now, let’s see how we can build one. I am going to use Python and will also provide an example using JavaScript. I won’t use many libraries — just requests for Python.</p><p>First, we need to import requests in Python:</p><pre>import requests</pre><p>Next, we’ll get the authorization token:</p><p>1 . Open your browser and go to Discord.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*M32I7RmAcg5U_rs6J6jXCQ.png" /></figure><p>2 . Right-click and select ‘Inspect’.</p><p>3 . Go to the ‘Network’ tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*WcXM0Vt8tHcFV8DFfRptUg.png" /></figure><p>4 . Click on any request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*HNXu1kleNGHLEMFui5O3gA.png" /></figure><p>5 Navigate to the ‘Headers’ tab.</p><p>6 . Find and copy the ‘Authorization’ token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*Nx7zKrRGpznbhkGCOJHgFA.png" /></figure><p>7 . Paste this token into your code:</p><pre>headers = {<br>    &quot;Authorization&quot;: &quot;your authorization token&quot;<br>}</pre><p>Now what is the message you are interested to send</p><pre>playload = {<br>    &quot;content&quot;: &quot;your message&quot;<br>}</pre><p>To send the message, we need the channel ID:</p><ol><li>Navigate to the channel where you want to send the message.</li><li>Right-click on the channel and select ‘Copy ID’.</li><li>Paste this ID into your code:</li></ol><pre>channel_id = &quot;your channel ID&quot;</pre><p>Now we are going to send the message.</p><pre><br>requests.post(f&quot;https://discord.com/api/v9/channels/{channel_id}/messages&quot;, headers=headers, data=playload)</pre><p>and that is it you have created a discord bot using python</p><p>The full code will be like this</p><pre>import requests<br><br>authorization = &quot;your authorization token&quot;<br>headers = {<br>    &quot;Authorization&quot;: authorization<br>}<br>payload = {<br>    &quot;content&quot;: &quot;your message&quot;<br>}<br>channel_id = &quot;your channel ID&quot;<br>requests.post(f&quot;https://discord.com/api/v9/channels/{channel_id}/messages&quot;, headers=headers, json=payload)</pre><p>also, you can make it inside a loop to send the message multiple times</p><pre>import requests<br>authorization = &quot;your authorization token&quot;<br>headers = {<br>    &quot;authorization:&quot; : authorization<br>}<br>playload = {<br>    &quot;content&quot; : &quot;your message&quot;<br>}<br>channel_id = &quot;your channel id&quot;<br>for i in range(10):<br>    requests.post(f&quot;https://discord.com/api/v9/channels/{channel_id}/messages&quot;, headers=headers, data=playload)</pre><p>Now let’s see how to do this using JavaScript:</p><pre>const fetch = require(&quot;node-fetch&quot;);<br>const authorization = &quot;your authorization token&quot;;<br>const headers = {<br>    &quot;Authorization&quot;: authorization<br>};<br>const payload = {<br>    &quot;content&quot;: &quot;your message&quot;<br>};<br>const channel_id = &quot;your channel ID&quot;;<br><br>fetch(`https://discord.com/api/v9/channels/${channel_id}/messages`, {<br>    method: &quot;POST&quot;,<br>    headers: headers,<br>    body: JSON.stringify(payload)<br>});</pre><p>And that’s how you create a Discord bot using Python and JavaScript. I hope this is helpful, and feel free to ask any questions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05e1ee9d5ded" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a telegram bot]]></title>
            <link>https://medium.com/@Elhazin/creating-a-telegram-bot-55e6ca4e337d?source=rss-d926e523a62b------2</link>
            <guid isPermaLink="false">https://medium.com/p/55e6ca4e337d</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[telegram]]></category>
            <category><![CDATA[bots]]></category>
            <dc:creator><![CDATA[Anas Bouzanbil]]></dc:creator>
            <pubDate>Wed, 15 Nov 2023 11:29:41 GMT</pubDate>
            <atom:updated>2023-11-15T11:29:41.771Z</atom:updated>
            <content:encoded><![CDATA[<p>Once, I was feeling bored, and I wanted to chat with someone because I was feeling incredibly lonely. That’s when I got the idea of creating a bot that could chat with me. I obtained a ChatGPT token (please note that ChatGPT token is not free), (but in this article we are just going to cover just chatbot telegram only) and learned some basic API concepts that I needed to use for the functions I had in mind.</p><p>Let’s get started.</p><p>First and foremost, you must have a Telegram account. Then, you need to talk to BotFather to create your bot. BotFather will provide you with a token for your bot. To do this, search for @<a href="https://web.telegram.org/a/#93372553">botfather</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*G0F-OjbEWl2fux_hJMf_jA.png" /></figure><p>and start the conversation by clicking on the start button. Next, type the command /newbot and follow the prompts and instructions given by BotFather. After completing the instructions, you will be given a token to authenticate your bot and grant it access to the Telegram API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0bgshBguNkj3oD9wJ3gJhA.png" /></figure><p>Now, let’s get our hands dirty by writing some code.</p><p>First, you’ll need to install the Python library called python-telegram-bot using the following command:</p><pre>pip install python-telegram-bot</pre><p>After that, create a Python file (e.g., your_file.py) and import all the necessary classes and components. Your import statements should look like this:</p><pre>from telegram import Update<br>from telegram.ext import Updater, CommandHandler, CallbackContext, MessageHandler, Application, filters</pre><p>Next, declare your Telegram bot token. Replace YOUR_BOT_TOKEN with the actual token you received from BotFather:</p><pre>TOKEN = &#39;YOUR_BOT_TOKEN&#39;</pre><p>Now, let’s set up the basic structure for your bot:</p><pre>if __name__ == &quot;__main__&quot;:<br>    app = Application.builder().token(TOKEN).build()</pre><p>This code creates an application (app) and initializes it with your bot&#39;s token. It&#39;s a crucial step in establishing a connection between your code and the Telegram API.</p><p>So far, we’ve done a good job. We’ve included the necessary library, created a variable for our bot’s token, and initialized an application with the token for our bot</p><p>Now, let’s create a function to handle the input from users chatting with your bot.</p><pre>async def handle_message(update: Update, context: CallbackContext):<br>    message = update.message.text  # In this line, you retrieve the message sent by the user.<br>    <br>    # Here, you can add your logic to handle different messages.<br>    if message == &quot;Hello&quot;:<br>        await update.message.reply_text(&quot;Hello there!&quot;)<br>    elif message == &quot;I love you&quot;:<br>        await update.message.reply_text(&quot;Who the hell are you?&quot;)<br>    else:<br>        await update.message.reply_text(&quot;What are you saying?&quot;)</pre><p>This function (handle_message) will be called whenever a message is received from the user. Now, let&#39;s integrate this function into the main part of your code:</p><pre>if __name__ == &quot;__main__&quot;:<br>    app = Application.builder().token(TOKEN).build()<br>    app.add_handler(MessageHandler(filters.TEXT, handle_message)</pre><p>Here, app.add_handler(MessageHandler(filters.TEXT, handle_message)) registers the handle_message function to be called whenever a text message is received</p><p>However, you need to add a function that will initiate your bot. In this function, you define how your script will fetch updates. The function responsible for starting your bot is run_polling().</p><p>The final version of the main function code will look like this:</p><pre>if __name__ == &quot;__main__&quot;:<br>    app = Application.builder().token(TOKEN).build()<br>    app.add_handler(MessageHandler(filters.TEXT, handle_message))<br>    <br>    # Start the bot.<br>    app.run_polling()</pre><p>Now, everything seems good. All you have to do is open a terminal, run the code, and then go to your bot to test if it is working or not</p><p>The final version of this code will be like this :</p><pre>from telegram import Update<br>from telegram.ext import Updater, CommandHandler, CallbackContext, MessageHandler, Application, filters<br><br>TOKEN = &#39;YOUR_BOT_TOKEN&#39;<br><br>async def handle_message(update: Update, context: CallbackContext):<br>    message = update.message.text<br>    <br>    if message == &quot;Hello&quot;:<br>        await update.message.reply_text(&quot;Hello there!&quot;)<br>    elif message == &quot;I love you&quot;:<br>        await update.message.reply_text(&quot;Who the hell are you?&quot;)<br>    else:<br>        await update.message.reply_text(&quot;What are you saying?&quot;)<br><br>if __name__ == &quot;__main__&quot;:<br>    app = Application.builder().token(TOKEN).build()<br>    app.add_handler(MessageHandler(filters.TEXT, handle_message))<br>    <br>    # Start the bot.<br>    app.run_polling()</pre><p>These are the basic steps I followed at the beginning to create my own Telegram bot. It’s not difficult to create one, and I simply wanted to share my basic experience in bot creation. I hope this guide helps others embark on their journey of building and experimenting with Telegram bots.</p><p>By <a href="https://medium.com/u/d926e523a62b">Elhazin</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55e6ca4e337d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dining Philosophers Problem]]></title>
            <link>https://medium.com/@Elhazin/dining-philosophers-problem-0e850e157d26?source=rss-d926e523a62b------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e850e157d26</guid>
            <category><![CDATA[1337]]></category>
            <category><![CDATA[dining]]></category>
            <category><![CDATA[philosopher]]></category>
            <category><![CDATA[42-network]]></category>
            <category><![CDATA[process]]></category>
            <dc:creator><![CDATA[Anas Bouzanbil]]></dc:creator>
            <pubDate>Wed, 15 Nov 2023 02:33:22 GMT</pubDate>
            <atom:updated>2024-10-13T12:03:47.459Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever heard of the dining philosophers problem? If not, let me provide you with a brief explanation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yTFIGS7GezG1vp4VZRtPCw.png" /></figure><p>Imagine five philosophers seated around a table, each with a plate of food and two forks. However, these philosophers are not like ordinary diners; they have a unique way of eating. To enjoy their meal, they need to use two forks simultaneously. This creates a challenge because, in order to eat, a philosopher must acquire the fork held by the philosopher on their left and the one held by the philosopher on their right. Meanwhile, the philosophers are engaged in a cycle of eating, sleeping, and thinking, with each activity dependent on the others.</p><p>Now, let’s shift our perspective from philosophers and forks to processes and computer resources. Think of these philosophers as processes and the forks as crucial computer resources. Picture a scenario where a process seeks access to a resource, and simultaneously, another process desires the same resource. This mirrors the dining philosophers&#39; problem, where a philosopher needs a fork to eat, and another philosopher might simultaneously be reaching for that same fork, leading to a potential issue.</p><p>To resolve this resource contention, we need to manage these resources more efficiently. In this article, I’ll tackle the Dining Philosophers Problem using the C language, treating each philosopher as a thread. The forks, essential for the philosophers to dine, will be represented as mutexes. However, the complete solution to the dining dilemma will be explored in a subsequent article. For now, our focus lies on understanding threads and mutexes</p><p>To create a thread in C, the process is straightforward. In our case, we’ll be working with two threads, representing them as two philosophers. Below is a snippet illustrating how to create threads in C:</p><pre>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;pthread.h&gt;<br><br>void* I_am_the_routine(void* arg) {<br>    int i = *((int*)arg);<br>    printf(&quot;I am the philosopher number %d\n&quot;, i);<br>    return NULL;<br>}<br><br>int main(void) {<br>    pthread_t *thread = malloc(sizeof(pthread_t) * 2);<br>    int a[2] = {1, 2};<br>    int i = 0;<br><br>    while (i &lt; 2) {<br>        pthread_create(&amp;thread[i], NULL, I_am_the_routine, &amp;a[i]);<br>        i++;<br>    }<br>    i = 0;<br>    while (i &lt; 2) {<br>        pthread_join(thread[i], NULL);<br>        i++;<br>    }<br><br>    free(thread);<br><br>    return 0;<br>}</pre><p>and congratulations now you have finished creating a thread . now let us create a forks for each philosopher</p><pre>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;pthread.h&gt;<br><br>typedef struct {<br>    int sharedInt;<br>    pthread_mutex_t mutex;<br>} SharedData;<br><br>void* philosopher(void* arg) {<br>    SharedData* sharedData = (SharedData*)arg;<br><br>    while (1) {<br>        pthread_mutex_lock(&amp;(sharedData-&gt;mutex));<br><br>        (sharedData-&gt;sharedInt)++;<br>        printf(&quot;Philosopher incremented the shared integer to %d\n&quot;, sharedData-&gt;sharedInt);<br><br>        pthread_mutex_unlock(&amp;(sharedData-&gt;mutex));<br>    }<br><br>    return NULL;<br>}<br><br>int main(void) {<br>    pthread_t threads[2];<br>    SharedData sharedData;<br>    sharedData.sharedInt = 0;<br>    pthread_mutex_init(&amp;(sharedData.mutex), NULL);<br><br>    for (int i = 0; i &lt; 2; ++i) {<br>        pthread_create(&amp;threads[i], NULL, philosopher, &amp;sharedData);<br>    }<br><br>    for (int i = 0; i &lt; 2; ++i) {<br>        pthread_join(threads[i], NULL);<br>    }<br><br>    pthread_mutex_destroy(&amp;(sharedData.mutex));<br><br>    return 0;<br>}</pre><p>This is how you will create mutexes, which represent the forks, and the threads that simulate the philosophers’ actions. Now, you just need to devise the logic to solve this problem. I have already solved this problem, and you can find the solution on my <a href="https://github.com/Elhazin/philosophers-dining-problem-c">GitHub repository</a>. We will continue discussing this topic in the next article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e850e157d26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git]]></title>
            <link>https://medium.com/@Elhazin/git-4bd24f07c0ba?source=rss-d926e523a62b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bd24f07c0ba</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Anas Bouzanbil]]></dc:creator>
            <pubDate>Tue, 14 Nov 2023 23:46:22 GMT</pubDate>
            <atom:updated>2023-11-14T23:46:22.436Z</atom:updated>
            <content:encoded><![CDATA[<p>A small definition of <a href="https://en.wikipedia.org/wiki/Git">Git</a>: it’s a tool that helps developers keep track of changes in their code!</p><p>Imagine you’re working on a document, and you want to save different versions as you make changes. In a typical situation, you might create separate files like “document1,” “document2,” and so on. However, with Git, you can save these changes more efficiently using specific commands that will be explained later on.</p><p>You may be confused or find yourself mixing up Git and GitHub. As mentioned earlier, Git is a tool that assists in tracking changes in your source code during software development. It helps manage collaboration among multiple developers and maintains a history of your project. On the other hand, GitHub is a web-based platform that utilizes Git for version control. It offers additional features beyond Git, including a graphical interface, issue tracking, pull requests, and more. GitHub enables developers to host their Git repositories in the cloud.</p><p>Now, let’s start with the basic Git commands. It’s important to note that there are many Git commands, each serving a specific purpose.</p><p>git init: This command initializes a new Git repository. You can use git init --help to get more information.</p><p>git clone: This command typically creates a copy of a remote repository on your machine.</p><p>git add: This command is used to add changes in your working directory to your repository. Its options include:</p><ul><li>-A: Similar to git add ., adds all changes, including untracked and removed files, to your remote repository.</li><li>-i: Opens an interactive mode, allowing you to choose which changes to add.</li></ul><p>git commit: This command is used to set a comment or a commit message for your push.</p><p>git status: Shows the status of changes as untracked or modified.</p><p>git push: This command pushes committed changes to a remote repository. Its options vary, such as:</p><ul><li>-f: Forcefully pushes your changes.</li><li>--all origin: Pushes to all branches.</li></ul><ol><li>git pull: This command is used to fetch and integrate changes from a remote repository into your current branch. It combines two actions: git fetch, which retrieves the changes from the remote repository, and git merge, which incorporates those changes into your local branch. This is particularly useful when collaborating with others, as it helps you stay up-to-date with the latest changes in the remote repository.</li><li>git checkout: The git checkout command is versatile and serves multiple purposes:</li></ol><ul><li>Switching branches: Use git checkout &lt;branch-name&gt; to switch from your current branch to another existing branch.</li><li>Creating a new branch: Use git checkout -b &lt;new-branch&gt; to create and switch to a new branch in one command.</li><li>Discarding changes: Use git checkout -- &lt;file&gt; to discard changes made to a specific file in your working directory.</li></ul><p>git merge: This command integrates changes from one branch into another. Typically, you use it to combine the changes made in a feature branch into the main branch. After fetching changes with git pull and switching to the target branch with git checkout, you can use git merge &lt;source-branch&gt; to merge the changes. This creates a new commit that consolidates the changes from both branches. In cases where there are conflicting changes, Git provides tools to resolve these conflicts before finalizing the merge.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bd24f07c0ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>