[{"content":" Introduction # Hello There! and welcome to my blog about learning git and GitHub as a beginner. Today we are going to dive into a really famous and also widely used version control system, which is git. Along with its helper-site that allows you to have a cloud space to manage a remote version of your project's code and other files. So without any further ado, let's dive into this tool shall we? Introduction To Git # As said before, git is a version control system for your project. But what does a version control system even mean ? A version control system is a system that allows you to track all the changes made in your project's files by keeping a log of its history. You can view this history any time using git commands. This also allows you to jump back to any older version of your project where you had not applied the latest changes. Benefits Of Using Git # Think of git as a safe system that allows you to manage your project in such a way that if anything goes wrong and your project starts to look like as if it is becoming a mess, you can just go back to a checkpoint where it was not a mess. Great thing isn't it ? Not to mention that git does all of this locally on your system meaning that the absence of an internet connection won't hinder your workflow at all, a developer's dream. When we get into GitHub later on, we will also discuss an additional feature that git provides us in the domain of collaboration with a team during project management. However, all the features related to GitHub will require a stable internet connection because GitHub is a hosted site and doesn't run on our local machine unlike git itself. Git Installation # With that out of the way, let's start with how to setup git in our system. This is gonna be an easy process don't worry and just follow along step by step slowly. First of all we need to download git, we can do this by going to git's official download site at \"Git Download Site\". You will see a page that looks like this. Now if you are installing git on windows, you can download any of these setups and follow the on-screen instructions to install git on windows, you don't really need to change any configurations while running the setup, just keep pressing next until it starts the installation. Now if you are installing git on Mac OS or a Debian Based Linux Distro, you can go to the Mac or Linux Tab and follow the given commands to install git. However, I am running Arch Linux and the git site doesn't provide the respective installation process so I will tell you how to do it on Arch as well. don't worry, all you need is a single terminal command: sudo pacman -S git After this, you can also verify the git installation using the following command:\ngit --version This command will show your installed version of git, this shows that git has been properly installed in your system and you are ready to move on with it. Now that we are done with installation of git, let\u0026rsquo;s start with orientation of GitHub as well to learn these tools in parallel and get the best out of them.\nIntroduction To GitHub # GitHub is basically a website that you can use in combination with git, this site allows you to have a cloud based management system for your projects. It also provides a more GUI approach towards git itself as well. Where git manages your project locally, GitHub manages it remotely. Basically when you use git and GitHub together, your project is saved in two forms. These two forms are: Local (On Your System) Remote (On Your GitHub) Ideally, you should keep both of these in sync so that your project stays updated and there are no gaps between your local data and remote data. Also, git and GitHub manage your project using Repositories. Repository is just a fancy name for a folder in GitHub terminology. In short, a repository is also called a \"Repo\". So you have a Local Repo and a Remote Repo. GitHub Setup # Now that we have already installed git, let's setup our GitHub so that we can get into learning them both. First you need to make an account on GitHub by going to the official GitHub site at \"GitHub Site\". Now you can make a GitHub account by entering your email and clicking \"Sign up for GitHub\" button, then you will need to verify your account using your email and the account will be created. Or if you already have a Google account, you can use that to sign-in as well using the sign-in option at the top right of this webpage as shown here. Since I already have a google account, I will login using that account and then we will go through the GitHub's understanding regarding its interface and all. GitHub GUI # When you sign in your GitHub's interface might look quite empty as compared to mine. That is because your account is new and you haven't added much to it yet whereas mine has been in use for quite a while now. Anyways, let's familiarize with GitHub's GUI. Here is an image of my GitHub's home page. If you take a look at that list on the left side of my GitHub's home page, these are my remote repositories that are managed by GitHub. Even this blogsite that you are looking at right now, its code is being maintained using git and GitHub, as you can see by looking at the bottom-most repo. So any repos that you will make are going to appear in this column later on. Then there is the \"News/Updates\" Section in the middle of the page which shows the latest updates of any activity on GitHub. That should be all for the home interface for now. Let's start configuring git. Git Configuration # When we are about to use git for the first time after installation, there are some one time commands that we need to run in order to configure git. First we need to tell it about the account that it will be handling on GitHub remotely. Username \u0026amp; Email # For this, we need to provide it with the username and email of that account. Now my name is coder-Retro and email is hasnainqadri9c@gmail.com, but you shall replace my credentials with yours. Username and email are configured as: git config --global user.name \u0026#34;coder-Retro\u0026#34; git config --global user.email \u0026#34;hasnainqadri9c@gmail.com\u0026#34; Verification # Then you can also verify your configuration using the following git command: git config --list This will show the current configured username and email that git is handling. After this one-time setup is done, let\u0026rsquo;s create our first Local Repo using git.\nRepository Setup # In order to make a local repo, we need to make a folder on our system. Name this folder as your project's name for easy management and organization. For example if our project is called Demo, then make a folder by the name \"Demo\". You can do this using command line by running the following command: mkdir Demo Then we need to enter this folder, you can do this by running the command:\ncd Demo Local Repo # By now, we are inside our project folder, now we need to turn this folder into a local repo using git. We can use git's repo initializing command for this purpose, this command is the most basic git command and it goes like this: git init git branch -M main What this does is that it turns the current folder into a local repo and the second command renames your current branch to \u0026ldquo;main\u0026rdquo;, by default it\u0026rsquo;s named as master. We will learn what a branch is when we get there, for now just let it slide and don\u0026rsquo;t sweat it. Git starts monitoring any files in this folder (Local Repo) from now on. Hence, git is active and in action now.\nRemote Repo # After this we need to make a remote repo using GitHub which we will then connect this local repo to. In order to create a remote repo, go to your GitHub's home page and look for the \"plus icon with a dropdown menu\" in the navigation bar. Click the dropdown arrow and you will see the following options in the list that appears: Select the \"New repository\" option. You will be greeted with repo creation page, name your remote repo same as your local repo for easy management. Since my local repo was named Demo, I will name remote as Demo too. For now, don't change any other settings and just click on \"Create repository\" button at the bottom right. Now you will be greeted with a new page that contains our repo's HTTPS URL which we need to copy. We need this to connect our local repo to remote repo. Copy the URL by clicking at the following button: Now we can go back to connect our local repo to remote repo using terminal. Connect Local to Remote # In order to connect our local repo to remote repo, run the following command but replace my repos HTTPS URL with your repo's: git remote add origin https://github.com/coder-Retro/Demo.git This command connects our local repo to the remote repo and allows the communication between both of them from now on, we can tranfer data from local to remote and vice versa now. Congratulations on making your first repository. Next up, we will learn how to add contents to our repos.\nAdd Files to Local Repo # Let's create a simple cpp file in our local repo and then try to save it to our remote repo as well. Let's create a simple test.cpp in our local repo: #include\u0026lt;iostream\u0026gt; int main(){ std::cout \u0026lt;\u0026lt; \u0026#34;This is my Demo Project\u0026#34;; return 0; } Now save this file in your local repo. Let\u0026rsquo;s see if git is tracking our file or not. For this, run the command:\ngit status You will see the following on your terminal:\nOn branch main No commits yet Untracked files: (use \u0026#34;git add \u0026lt;file\u0026gt;...\u0026#34; to include in what will be committed) .vscode/ test.cpp nothing added to commit but untracked files present (use \u0026#34;git add\u0026#34; to track) This means that git is not tracking your test.cpp yet, in order to make git track it, run the following command:\ngit add . This command tells git to track all the files in the current folder. Now run the status command again and you will see this now:\nOn branch main No commits yet Changes to be committed: (use \u0026#34;git rm --cached \u0026lt;file\u0026gt;...\u0026#34; to unstage) new file: test.cpp This means that git has started tracking your test.cpp.\nAdd Files to Remote Repo # Now let's save this file onto our remote repo as well using the following two commands: git commit -m \u0026#34;Any Message\u0026#34; git push origin main The first command creates a snapshot of your current added file. Then the second command sends that snap shot to the main branch in your remote repo.\nGitHub Authentication # When you run git push origin main for the first time, your terminal will prompt you for a Username and Password. Do not enter your standard GitHub account password! Since 2021, GitHub requires a Personal Access Token (PAT) for command-line operations. Here is how to fix this. Go to your GitHub settings: Go to Developer settings Go to Personal access tokens Go to Tokens (classic) Click \"Generate new token (classic) Give it a name (e.g., \"GitCLI\"), and check the repo box. Click \"Generate token\" and copy it immediately Note: You won't be able to see it again! Enter this token when your terminal asks for your \"Password.\" After you are done with this procedure, run this command again. git push origin main Now if you go back to you GitHub and open the Demo repo and refresh the page. You will see that your test.cpp has appeared in remote repo. You will also see the text \u0026ldquo;Any Message\u0026rdquo; in front of it, this is called a commit message and people use it to determine what change they performed in the pushed file.\nGitignore File # Now if you are using vscode as your editor, you might have noticed that a folder by the name of .vscode might have appeared aside from your test.cpp, vscode stores some language based settings in this folder. However we don't want to push this folder to our repo but it still appears when we try to push our test.cpp, so let's tell git to ignore this folder using a really useful file that git offers us, \".gitignore\". First, create a new file named exactly .gitignore in the root of your local project folder (make sure it starts with a dot and has no extension like .txt). Open it, type the following folder exclusion pattern in your \".gitignore\": .vscode/ Then save and close it. Now, because we ran git add . in our previous step, Git has already indexed and started tracking our .vscode/ folder! Simply creating a .gitignore file won\u0026rsquo;t stop git from tracking files it has already noticed. We need to clear it from git\u0026rsquo;s active tracking memory first. Run this specific sequence of commands to untrack the folder and push your new rules to GitHub:\ngit rm -r --cached .vscode git add .gitignore git commit -m \u0026#34;Add: .vscode to gitignore\u0026#34; git push origin main The first command tells Git to safely drop .vscode/ from its tracking registry without deleting the actual files from your hard drive. The subsequent commands log your .gitignore rules into your history and upload them. If you open your remote repo on GitHub, you will notice that the .vscode/ folder has vanished from the cloud while remaining fully intact on your machine. From this point forward, Git will silently ignore it on every single push.\nJust now, we pushed our code directly to main branch in the repo, for now it's okay since we are learning git and GitHub as beginners but later on we will learn how it is not recommended to push directly to main branch. In order to understand this, we need to learn what branches are and how to use them. But before moving on to that, I recommend taking a break and practice all that you have learnt up until now to let it sink in. When you have developed a good grasp on it, continue to branches. Working Tree \u0026amp; Branches # When we are working on git and GitHub, we need to know how it is structured and handled inside our repo, basically our entire project is organized similar to a tree structure and you can say the branch that we just pushed our test.cpp to, yes the \"main branch\" is the trunk of this tree. Our main branch holds the deployed version of our project which means that all the code on our main branch, is deployed in the field. Then how do we add new features to it? How do we maintain the features without compromising the main deployed code? How do we test and experiment with new features without ruining our actual project? That is where feature branches come in. A feature branch is basically a branch that diverges out of the main branch, we use this branch to create a separate copy of our project and work on that copy so that we don't modify the actual project on the main branch. When our modifications are completed and we have tested the new feature, we merge our feature branch back into our main branch to apply these new features to the deployed project. This entire branch structure is called a \"Working Tree\". So basically when you are working on your project, it is preferred to make a feature branch and work on that so that your main project remains safe. And this is why it is not recommended to push directly onto the main branch as we did before. Now that we have learnt what a branch is, let's try to make one and then we will use that branch to add some more features to our test.cpp. Feature Branch # Before making our feature branch, it is a convention that we must sync our local repo to our remote repo. We can do this by running the following command in our terminal: git switch main git pull origin main The first command makes sure that we are on our main branch. If you are already on the main branch, you can skip this command. Then, the second command fetches the files from remote repo onto our local repo to make sure that our local repo has the latest updates before we start working on anything. First we need a name for our feature branch, for now we will name it \u0026ldquo;feature-branch\u0026rdquo;. Now let\u0026rsquo;s make our feature branch by running this command:\ngit switch -c feature-branch This command not only makes a new feature branch but also takes us to it. You can also check which branches your have in your repo and your currently active branch by running this command:\ngit branch You will see the list of all current branches on your repo and your currently active branch will be marked with a \u0026ldquo;*\u0026rdquo; symbol. My Demo Repo\u0026rsquo;s branch list looks like this right now:\n* feature-branch main The \u0026ldquo;*\u0026rdquo; symbol shows that I am currently working on the feature branch, you can switch between branches using any of the following two commands:\ngit checkout targetBranchName git switch targetBranchName Now anything we do on this feature branch will not modify the main branch itself. Let\u0026rsquo;s verify this by editing the test.cpp on this feature branch. Open your test.cpp and add a line in the main function after the last cout:\n#include\u0026lt;iostream\u0026gt; int main(){ std::cout \u0026lt;\u0026lt; \u0026#34;This is my Demo Project\u0026#34;; std::cout \u0026lt;\u0026lt; \u0026#34;\\nThis is a Feature\u0026#34;; return 0; } Save your file and then add, commit and push it to your feature branch using the previously learnt commands:\ngit add test.cpp git commit -m \u0026#34;feat: Added Feature\u0026#34; git push origin feature-branch Now go to your GitHub and open your test.cpp, your will see something like:\nAs you can see, the code hasn't changed. This is because we pushed the code to feature branch this time and not the main branch. Let's look at the code in our feature branch to see if our changes are showing there. You can do this by opening the branch drop down menu and selecting feature branch as shown: This will take you to your feature branch and now you can see the updated feature code that you have pushed to your feature branch. It should look something like this: Merge Feature Branch # So now, we know how to update our local repo to remote repo, make a feature branch and switch to it, modify file on the feature branch and push it to feature branch, how to view our feature branch on GitHub. All while not disturbing the main branch. Now let's say that our feature is working perfectly fine and we know that it is ready to be deployed. Then we need to merge our feature branch back into main branch. There are two ways you can do this: Through Command Line using git Creating Pull Request using GitHub Git Method # If you are working on your project as a solo developer in your personal repository then git method is the most suitable for this scenario. For this, you need to first switch to your main branch and then run the merge command as: git switch main git merge feature-branch git push origin main The first command switches control to your main branch in local repo, the second command merges the updated files from your feature branch into your main branch in local repo, then the third command updates your remote repo\u0026rsquo;s main branch with these modifications as well. You can verify these change by going onto your GitHub and checking the file in main branch to see updates.\nGitHub Method # If you are working on a project with a team in a collaborative repository, it's preferred to use the GitHub method which requires you to generate a \"PR\", which stands for \"Pull Request\". It is basically a sort of letter that carries your updated file from your feature branch attached with it. Your team first reads your file to make sure that it doesn't require any changes to be made before it goes into the main branch for merge. When you are provided a certain number of approvals by your team, then you are allowed to merge your feature branch back into the main branch. This makes sure that one individual doesn't accidentally alter the main branch without the approval of the team. Let's learn how to generate a PR now after pushing to our remote repo's feature branch. First, go to your remote repo on GitHub. You will see an option to \"Compare and Create Pull Request\" that came when you pushed to remote's feature branch. However if you don't see this option, simply click on \"Pull Requests\" as shown here: Then you will come to \"PR section\", from here you can generate your PR using the \"New Pull Request\" button at the top right of this section as shown in here. You will be greeted with the file that you are about to send along with your PR to be merged into the main, review the file and make sure that it is as you intended it to be, like my file has my added feature line in it as shown here: Then click on the \"Create Pull Request\" button at the top right of this section and you will be taken to the final configuration for your PR. Here you will select a title (first highlight), then provide a description (second highlight) and finally click on \"Create Pull Request\" (third highlight) at the bottom of this page. This will finalise and submit your PR for your team to review before you can merge. Now go back to \"Pull Requests\" tab and you will see your PR waiting there, click it to open it and check the current status of our PR. If you are working with an actual team in a collaborative Repo, you will see something like this in your PR: Merging will be blocked until a specified number of people from your team have approved your PR. For now, this is my own repo so I have set the number of required approvals to 1 and then I asked one of my amazing friends to volunteer as a reviewer for my PR. So I invited my friend \"Velanora\" as a collaborator in my Demo Repo. Let's add her as a reviewer on this PR so she can review and approve it for us which will allow us to merge our feature branch into main branch then. We can add her as a reviewer by selecting her from the \"Reviewer's Menu\" like this: After we select a reviewer by clicking on them, we can save them by clicking outside the reviewer's menu. Our Reviewer will receive a notification from GitHub telling them about their required approval in our PR. Then we will have to wait for them to review our PR. We can see that our reviewer has approved our PR or not by a symbol next to their name in Reviewer list on the right side. If the symbol is a yellow dot, they have not approved our PR, if the symbol is a blue/green tick, they have approved the PR. After reviewing, our reviewer can either request changes or they can approve it depending on the requirement of the project. If they request changes, we will still be barred from merging then, but if they approve our PR, yellow dot will be replaced with a blue/green tick and we will be allowed to merge. Once our PR has gotten the required amount of approvals, we can go back to our PR and we will see that our merge option has been unlocked. If everything has gone accordingly, our PR should have an unlocked merge option like this: Now let's merge our PR by clicking on the \"Merge Pull Request\" button at the bottom, a dialogue box will appear where we have to provide a commit message, a description if we want and finally click the \"Merge Pull Request\" button like this one: Then finally our PR will be merged into main and you will see this appear at the bottom of your PR: Now it is a convention to delete a branch after it has merged into main and completed the task it was supposed to do, but before deleting it let's see that our changes have safely merged into our main branch by going to main branch on GitHub. Delete Feature Branch # As we can see that our main has successfully been updated and now we can safely delete our feature branch using the command line in our terminal. We will need the following commands: git switch main git pull origin main git branch -d feature-branch git push origin -d feature-branch The first command will switch us to main because in order to delete a branch, we need to move to another branch as git does not allow you to delete your currently active branch. So first command will switch us to main. Then second command will update your local\u0026rsquo;s main to remote\u0026rsquo;s main (updated after merge). Then third command will delete our feature branch in our local repo. And finally fourth command will delete our feature branch from our remote repo on GitHub. You can verify the deletion of your local repo\u0026rsquo;s feature branch by running:\ngit branch You will see that your feature branch is deleted in your local repo. Similarly you can verify the deletion of your remote feature branch by going to the branch switch menu of your repo on GitHub:\nCongratulations! you have learnt how to create a feature branch, add a feature to your project, merge your branch using either git commands on your personal solo repo and by opening a PR on a collaborative repo. Then you also learnt how to delete your feature branch. Now you should take a break and practice all these concepts to let them sink in. Clone Repo # Now that we know how to make a repo from scratch, let's try working on a GitHub repo that we find amusing due to any certain reason. This is called cloning. For this, we need to clone the repo, how to do that ? First go to the location in your system where you want to save it. Then run the following command: git clone TargetRepoURL You can find the repo\u0026rsquo;s URL on GitHub in the blue/green \u0026ldquo;Code Menu\u0026rdquo; when you open that repo, for example let\u0026rsquo;s say we want to clone the Demo Repo we have been working on, then we would copy the given URL from the Repo on GitHub and replace the \u0026ldquo;TargetRepoURL\u0026rdquo; with it:\nThis command would clone the repo and then you can enter the local clone repo using: cd TargetRepoName However, do know that the repo might be owned by someone else and they might not have given you the rights to push anything to the remote repo like a collaborator could do. So you can play around with the local repo, but not the remote version of this cloned repo. Other than that, making branches and merging into main in your local repo is all the same as studied before. So now you know how to make a repo from scratch as well as how to clone a built one. Now we can move onto the actual core concepts of git and GitHub, basically the version control part of it, that allows us to track the changes made to files in our project and also to load old checkpoints if needed.\nBasic Version Control # Version control as discussed before, allows us to go to different points in the history of our project's evolution. How to do this now. Let's say that we want to remove the feature that we added using our feature branch into test.cpp. We can use version control capability of git to revert the commit in which we added the feature. Let's learn how to do this. For this, we will need the commit hash of that version. How to find that ? We run a simple command: git log You will see the history of all the commits made to the project. My Demo Repo\u0026rsquo;s History looks like this right now:\ncommit 6998eaa85661853059f2bd76249662a63df64ce8 (HEAD -\u0026gt; main, origin/main, origin/HEAD) Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Sun Jun 14 18:14:56 2026 +0500 feat: Added Feature commit a502c4a53ae37f001db0555b325fd3339f5db4bf Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Sun Jun 14 18:12:00 2026 +0500 Add: .vscode to gitignore commit 08964f140eee9b70a2f462094fd5947eb933d820 Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Sun Jun 14 18:07:58 2026 +0500 Any Message If you want to start reading the commit history from the beginning of the project, then read the git log\u0026rsquo;s output from bottom to upwards. As you can see here that there are only three commits. Initial commit that we made through our main branch (Any Message), second commit where we added the gitignore and the third commit that we made through our feature branch (feat: Added Feature). Git log also tells us the time those commits were made along with the attached commit message. Now back to commit hash that we needed. You see the first line of each commit that says \u0026ldquo;commit\u0026rdquo; and then a long code after it, this long code is called the \u0026ldquo;Commit Hash\u0026rdquo;.\nRevert Commit # In order to revert our feature commit, we need its commit hash. We can look at the commit messages to know where we want to go. The last commit says \"feat: Added Feature\", so that's the one we need to revert. Let's copy the commit hash of this commit. Now in order to remove a feature, we must make a new branch like we made one to add it. Let's revise the branch making process shall we? First sync your local main with remote main using: git switch main git pull origin main Then make a branch using the branch creation command and also switch to it. Let\u0026rsquo;s call this branch \u0026ldquo;remove-feature\u0026rdquo;:\ngit switch -c remove-feature Now let\u0026rsquo;s run branch list command to make sure that our branch has been created and we are on the current branch:\ngit branch It should look something like this:\n* remove-feature main Not let\u0026rsquo;s use our copied commit hash to revert the feature. For this, we need to run this command using our commit hash:\ngit revert --no-edit 6998eaa85661853059f2bd76249662a63df64ce8 git push origin remove-feature Normally \u0026ldquo;git revert CommitHash\u0026rdquo; would have also worked, but sometime you will get an error regarding an editor called \u0026ldquo;vi\u0026rdquo; which might not be installed in your system, so to bypass that error we use the \u0026ldquo;no-edit\u0026rdquo; flag. Now the test.cpp in the remove-feature branch of our repo has been restored to its original form where the feature did not exist.\nNow let's merge our remove-feature into our main to restore the original code as well: git switch main git merge remove-feature git push origin main The first command will switch to main branch in local repo, the second command will merge the remove-feature of local repo into main branch of local repo and finally third command will update the code on remote repo\u0026rsquo;s main branch using the local repo\u0026rsquo;s main. Now let\u0026rsquo;s run git log to verify if our feature has been removed, you will see this:\ncommit 69a0bcc56c2173ab9e01ad92fcc1fe7f872adb3d Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Sun Jun 14 21:53:54 2026 +0500 Revert \u0026#34;feat: Added Feature\u0026#34; This reverts commit 6998eaa85661853059f2bd76249662a63df64ce8. commit 6998eaa85661853059f2bd76249662a63df64ce8 Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Sun Jun 14 18:14:56 2026 +0500 feat: Added Feature commit a502c4a53ae37f001db0555b325fd3339f5db4bf Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Sun Jun 14 18:12:00 2026 +0500 Add: .vscode to gitignore commit 08964f140eee9b70a2f462094fd5947eb933d820 Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Sun Jun 14 18:07:58 2026 +0500 Any Message As you can see that the latest commit says (Revert \u0026ldquo;feat: Added Feature\u0026rdquo;). You can also verify the feature removal by going to remote repo\u0026rsquo;s main:\nCleanup # As we can see that our feature has been reverted all over our project and initial form of code has been restored. Now all we have left to do is to delete our remove-feature branch to cleanup. Let's revise the branch deletion process by running the following commands: git switch main git pull origin main git branch -d remove-feature git push origin -d remove-feature We already know what each of these commands do step by step. Congratulations on reverting your feature and restoring an older version of your project. This is one of the most important and amazing powers a developer can desire to have and that is exactly what git and GitHub deliver.\nAdvanced Version Control # That was not much to revert a single commit and restore the code. However, let's learn how to undo multiple commits that were made after a certain point. For this, we will add 3 features using 3 branches. We will use separate names for these branches (i.e feature-1, feature-2 and feature-3). Then we will restore the code to the point where only the feature of feature-1 was added and remove features added by feature-2 and feature-3. Let's make these branches and add the features first. git switch main git pull origin main git switch -c feature-1 Then add the feature in your cpp using feature-1:\n#include\u0026lt;iostream\u0026gt; int main(){ std::cout \u0026lt;\u0026lt; \u0026#34;This is my Demo Project\u0026#34;; std::cout \u0026lt;\u0026lt; \u0026#34;\\nThis is Feature 1\u0026#34;; return 0; } Now save it, push it onto remote\u0026rsquo;s feature-1, then merge it into main and delete your feature-1 using:\ngit add test.cpp git commit -m \u0026#34;Add: First Feature\u0026#34; git push origin feature-1 git switch main git merge feature-1 git push origin main git branch -d feature-1 git push origin -d feature-1 By now, first feature has been added and feature-1 has been deleted from local and remote repo. Let\u0026rsquo;s add second feature by making feature-2 branch. Now since we are already on main and we know that our local\u0026rsquo;s main is updated with remote\u0026rsquo;s main, we will skip the \u0026ldquo;git switch main\u0026rdquo; and \u0026ldquo;git pull origin main\u0026rdquo; command. This is important to know which command does what and whether we need to run it or not:\ngit switch -c feature-2 Then add the second feature to your test.cpp like:\n#include\u0026lt;iostream\u0026gt; int main(){ std::cout \u0026lt;\u0026lt; \u0026#34;This is my Demo Project\u0026#34;; std::cout \u0026lt;\u0026lt; \u0026#34;\\nThis is Feature 1\u0026#34;; std::cout \u0026lt;\u0026lt; \u0026#34;\\nThis is Feature 2\u0026#34;; return 0; } Now save test.cpp and repeat the same push and merge process for feature-2 as well:\ngit add test.cpp git commit -m \u0026#34;Add: Second Feature\u0026#34; git push origin feature-2 git switch main git merge feature-2 git branch -d feature-2 git push origin -d feature-2 I have demonstrated the process two times for First and Second feature. Now add the Third Feature using feature-3 branch yourself. By the end, we will be on our main branch, all feature branches will be deleted and your test.cpp will look like this:\n#include\u0026lt;iostream\u0026gt; int main(){ std::cout \u0026lt;\u0026lt; \u0026#34;This is my Demo Project\u0026#34;; std::cout \u0026lt;\u0026lt; \u0026#34;\\nThis is Feature 1\u0026#34;; std::cout \u0026lt;\u0026lt; \u0026#34;\\nThis is Feature 2\u0026#34;; std::cout \u0026lt;\u0026lt; \u0026#34;\\nThis is Feature 3\u0026#34;; return 0; } So we added three features using 3 feature branches, now we need to learn how to remove everything added to our project ahead of a certain point. For now, let\u0026rsquo;s set this point as First Feature, which means that we will restore the project to the point where First Feature was added and anything added after that (Second Feature and Third Feature) will be removed. This is gonna be different than reverting, where reverting only undid a single commit, this will undo all the commits made after \u0026ldquo;Add: First Feature\u0026rdquo;, therefore the successive \u0026ldquo;Add: Second Feature\u0026rdquo; \u0026amp; \u0026ldquo;Add: Third Feature\u0026rdquo; commits will be undone. Let\u0026rsquo;s get down to it then.\nRetrieve CommitHash # In order to restore our project to a certain point, we will need the commit hash of that point. We already know how we can get the commit hash using git log. Now since we need the commit hash of First Feature, we will need to search for the First Feature commit in the git log's history. But since we have been using clean commit messages for each commit, we will be able to locate First Feature's commit in no time. Let's open the project's commit history using: git log And we will be greeted with the history of commits of our project. Let\u0026rsquo;s look for the First Feature commit by searching through the commits using commit messages as a key. We are looking for a message that says \u0026ldquo;Add: First Feature\u0026rdquo;.\ncommit f3e2cd94b60ff4845dd3c80851a0f2ce6f6dd55f (HEAD -\u0026gt; main, origin/main, origin/HEAD) Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Tue Jun 16 19:33:09 2026 +0500 Add: Third Feature commit a65d42aad6606b6c8aaae3d649ec45735f76ad4c Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Tue Jun 16 19:31:42 2026 +0500 Add: Second Feature commit fe312a3b08b8d16a3ac6a110a987d8a0ef307a0c Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Tue Jun 16 19:29:53 2026 +0500 Add: First Feature commit 69a0bcc56c2173ab9e01ad92fcc1fe7f872adb3d Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Sun Jun 14 21:53:54 2026 +0500 Revert \u0026#34;feat: Added Feature\u0026#34; This reverts commit 6998eaa85661853059f2bd76249662a63df64ce8. commit 6998eaa85661853059f2bd76249662a63df64ce8 Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Sun Jun 14 18:14:56 2026 +0500 feat: Added Feature commit a502c4a53ae37f001db0555b325fd3339f5db4bf Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Sun Jun 14 18:12:00 2026 +0500 Add: .vscode to gitignore commit 08964f140eee9b70a2f462094fd5947eb933d820 Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Sun Jun 14 18:07:58 2026 +0500 Any Message There it is, the commit message \u0026ldquo;Add: First Feature\u0026rdquo;. We will now copy its commit hash. Now after that, we need to start restoration to this commit hash.\nRestoration # Now let's make another branch to start our retoration safely, let's name this branch as \"restore-branch\": git switch -c restore-branch Now we have to restore our project for First Feature on this branch and then update main branch using this branch as reference. We can do this by first restoring the code on our restore-branch by using the following command with First Feature\u0026rsquo;s commit hash:\nWarning Data Loss: The upcoming command contains a \u0026ldquo;hard\u0026rdquo; flag, which is a destructive flag. It completely wipes out files in your local directory and also wipes the git log history of the successive commits. Make sure you don\u0026rsquo;t have uncommitted code that you don\u0026rsquo;t want to lose before running this next command!\ngit reset --hard fe312a3b08b8d16a3ac6a110a987d8a0ef307a0c What this will do? this will bring the test.cpp on your restore-branch to the exact state as when First Feature was added, \u0026ldquo;hard\u0026rdquo; flag is the thing responsible for restoring the physical file to this point, if you use \u0026ldquo;soft\u0026rdquo; flag then your file would be staged as First Feature commit, but the physical code would not have been lost in your code editor. Anyways, \u0026ldquo;hard\u0026rdquo; resets the file to that commit. You can verify this by the absence of Second and Third Features in your test.cpp file in your code editor. Now we just need to update main using this restore-branch. We can do that by running the following commands:\nWarning History Rewriting: The upcoming commands contain a \u0026ldquo;force\u0026rdquo; flag which is capable of altering the remote repo\u0026rsquo;s history of commits made in the project, so before using this flag make sure that you don\u0026rsquo;t lose any neccessary data in your project\u0026rsquo;s history log which might be needed later. In a professional repo with a team, force-pushing to a shared tracking branch like main is usually strictly forbidden because it can disrupt your team\u0026rsquo;s local environments. Only use it on your personal or isolated feature branches!\ngit push origin restore-branch --force git switch main git reset --hard restore-branch git push origin main --force The first command, you already know what it does but that \u0026ldquo;force\u0026rdquo; flag is new for you right? Well GitHub has a simple rule called the forward-movement principle. It only expects the user to move forward by keeping all the previous commits and adding new ones ahead of it. But here, we just restored the restore-branch to an older commit which removed the successive commits (Second Feature \u0026amp; Third Feature), now if we push to GitHub, this will be a backward-movement which GitHub sees as a mistake by the user. So by adding \u0026ldquo;force\u0026rdquo; flag, we are telling GitHub that \u0026ldquo;I know what I am doing so just listen to me and do it\u0026rdquo;. This allows GitHub to know that this backward-movement is intentional and not a mistake so GitHub breaks its forward-movement principle and allows us to go back to an old point and remove the successive commits ahead of that point. It will also remove the Second Feature and Third Feature\u0026rsquo;s commits from our project\u0026rsquo;s git log history as well. That\u0026rsquo;s what the \u0026ldquo;force\u0026rdquo; flag does. The second command then switches to main as you know already. The third command updated the local\u0026rsquo;s main to local\u0026rsquo;s restore branch. The fourth command then updates remote\u0026rsquo;s main using local\u0026rsquo;s main, and \u0026ldquo;force\u0026rdquo; flag is again used for the same reason here. Now let\u0026rsquo;s run git log to check the history:\ncommit fe312a3b08b8d16a3ac6a110a987d8a0ef307a0c Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Tue Jun 16 19:29:53 2026 +0500 Add: First Feature commit 69a0bcc56c2173ab9e01ad92fcc1fe7f872adb3d Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Sun Jun 14 21:53:54 2026 +0500 Revert \u0026#34;feat: Added Feature\u0026#34; This reverts commit 6998eaa85661853059f2bd76249662a63df64ce8. commit 6998eaa85661853059f2bd76249662a63df64ce8 Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Sun Jun 14 18:14:56 2026 +0500 feat: Added Feature commit a502c4a53ae37f001db0555b325fd3339f5db4bf Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Sun Jun 14 18:12:00 2026 +0500 Add: .vscode to gitignore commit 08964f140eee9b70a2f462094fd5947eb933d820 Author: coder-Retro \u0026lt;hasnainqadri9c@gmail.com\u0026gt; Date: Sun Jun 14 18:07:58 2026 +0500 Any Message As you can see, latest commit is First Feature now and successive commits have been removed. You can also verify the change in you remote repo\u0026rsquo;s main.\nCleanup # Now that we have verified the restoration, let's perform the cleanup by deleting our restore branch from both local and remote repo. Again, I will skip the \"git switch main\" and \"git pull origin main\" because I am already on main branch so don't need to switch, and also main hasn't been changed after the last update, so we don't need to pull from remote's main: git branch -d restore-branch git push origin -d restore-branch There we go, project restored to intended point and all cleaned up. Again, I would recommend to take a break here and practice what you have learnt in Basic and Advanced Version Control to get a good understanding of it. After that, we will move onto our last topic of this git \u0026amp; GitHub guide, which is \u0026ldquo;Merge Conflicts\u0026rdquo;.\nMerge Conflict # Let's start with the theoretical definition and reasons of merge conflict. When two branches edit the same line in the same file and the first branch merges normally, but then the second branch will face a conflict when it tries to merge, git falls into a decisive scenario regarding whose modifications to keep and whose to discard. Now git doesn't have decision making capabilties, this scenario is called a \"Merge Conflict\". Resolution # Since git or GitHub don't know what to do, they tell the human about the rising conflict and ask the human to decide which changes should be kept and which should be discarded. This is the \"Manual Part\" of git and GitHub where they rely on us, just like we relied on them the whole project. Form Merge Conflict # It's better to learn this process using the GitHub merge method instead of git method, because merge conflicts usually arise when multiple people are working together in the same file, and you don't usually have multiple people working on the same local machine, so most merge conflicts occur in a collaborative repo. For this, let's try making two branches as if it were two different users, and then edit the same line in test.cpp to give rise to a merge conflict and then we will resolve it. Let's start by making both branches: git switch -c branch-1 git switch -c branch-2 Now if we run:\ngit branch We will see something like this:\nbranch-1 * branch-2 main Now let\u0026rsquo;s use branch-2 to edit a line in test.cpp. Open the test.cpp and make input a line like this:\n#include\u0026lt;iostream\u0026gt; int main(){ std::cout \u0026lt;\u0026lt; \u0026#34;This is my Demo Project\u0026#34;; std::cout \u0026lt;\u0026lt; \u0026#34;\\nThis is Feature 1\u0026#34;; std::cout \u0026lt;\u0026lt; \u0026#34;\\nThis is Branch-2\u0026#39;s edit\u0026#34;; return 0; } Now let\u0026rsquo;s update branch-2\u0026rsquo;s remote:\ngit add test.cpp git commit -m \u0026#34;Add: Branch-2 edited line 5\u0026#34; git push origin branch-2 Now let\u0026rsquo;s switch to branch-1 and edit the same line of test.cpp using branch-1:\ngit switch branch-1 After this, open test.cpp and add this line:\n#include\u0026lt;iostream\u0026gt; int main(){ std::cout \u0026lt;\u0026lt; \u0026#34;This is my Demo Project\u0026#34;; std::cout \u0026lt;\u0026lt; \u0026#34;\\nThis is Feature 1\u0026#34;; std::cout \u0026lt;\u0026lt; \u0026#34;\\nThis is Branch-1\u0026#39;s edit\u0026#34;; return 0; } Now save the file and push it to remote branch-1:\ngit add test.cpp git commit -m \u0026#34;Add: Branch-1 edited line 5\u0026#34; git push origin branch-1 Let\u0026rsquo;s perform the merge process by first opening a PR for each branch. Let\u0026rsquo;s revise the GitHub merge method while doing this. First we need to go to GitHub. Now we will see an option for both branch\u0026rsquo;s pull request on the main page right now, if they don\u0026rsquo;t appear then we can open PR\u0026rsquo;s by going to PR tab as well. Since we have already learnt how to do that before, you can use that method as well. I will directly click the following button for now:\nThen add a description if you want and click the \"Create Pull Request\" button to submit a PR for branch-1's merge and PR will be generated. You will notice that everything is normal and PR is allowed to merge withouth any problems. Now go to main page of your repo and do the same process for branch-2's PR submission. Also, since I haven't applied any security checks in my personal repo to PRs, I am getting this dialogue box: If you are getting this too in your personal repo, just ignore it right now because in a professional repo with a team, security checks will be applied and this box wont appear. For now, just perform the same PR opening process for branch-2 yourself like I did for branch-1. When you have successfully opened a PR for branch-2 just merge it right there using the Merge button at the bottom. You will notice that branch-2 safely merged and everything is normal up until this point, but now if you go to PR tab and open the PR of branch-1, you will see this: That is a \"Merge Conflict\", this happened because branch-2 that just merged into main, edited the same line 5 in test.cpp that our branch-1 has changed. Now GitHub is telling us about this conflict by showing us \"Merge Conflict\". You can also see that our merging has also been locked. Merging wont open again until merge conflict has been resolved. Let's learn how to resolve this. Resolve Merge Conflict # We can resolve the merge conflict directly on GitHub. Let's start. First click on this \"Merge Conflicts\" warning at the top right: This will open this side panel in which you have to click this \"Resolve Conflicts\" button: Finally you will be greeted with the file having the merge conflict, GitHub will show you the changes made by your predecessor and the changes made by you as well separately. Along with that, it will also give you the option to keep your changes and discard the predecessor's, keep predecessor's changes and discard yours, or even keep both the changes. You can select whichever is needed depending on the scenario. This is the part where team communication comes in, such a scenario shall be discussed with team and only then should such a decision be taken. For now, I will keep both changes. For this, I will click the third option: Also in the case of accepting both changes, you might notice that GitHub puts your changes first and then your predecessor's. So review the file to make sure if that is the order your file requires. In a code file, an error in the sequence of the statements can cause unwanted behaviour. So double check the sequence and then click the \"Mark as resolved\" button at the top right: Then you have to click the \"Commit Merge\" button to update your PR: You will now see that your PR doesn't have the merge conflict warning anymore and it says ready to merge, and if have attained the number of required reviews then your merge option shall also be unlocked now: Merge your PR by using the merge PR option at the bottom, you will see that your PR has successfully been merged into the main, you can verify this by going to main if you want. Cleanup # Now let's go back to our terminal and update our local repo's main to remote's main. And also delete branch-1 and branch-2 to perform the cleanup. git switch main git pull origin main git branch -d branch-1 git push origin -d branch-1 git branch -d branch-2 git push origin -d branch-2 Your can run git branch to verify the cleanup if you want. Congratulation! you have learnt what merge conflicts are, how they form and how you can fix them. We are officially done with our git and GitHub guide so let\u0026rsquo;s delete our Demo repo and mark an end to this journey. You can delete a Repo by going to the \u0026ldquo;Settings\u0026rdquo; tab on GitHub.\nThen scroll to the bottom of the page and you will see a \"Delete This Repository\" button, click it: It will ask you to confirm that you want to delete the Repo. If you don't need the repo and are sure to delete it, confirm it. It might ask you to retype the Repo name, so just copy it from the above and paste it below: Now normally you would be sent a code to your email which you need to enter here and delete the repo, but if someone has setup the \"GitHub Mobile App\" then you will see a \"Number\" on your system's screen, and now you need to open the app and enter that \"Number\". Either way, Repo will be deleted. Summary # In this guide, we learnt: Git Setup GitHub Setup Repo Setup Pushing Files to Repo Cloning Repo Branch Management Branch Merging Basic Version Control Advanced Version Control Merge Conflict With these skills, you have developed all the ability to handle a project using git and GitHub, whether it is your solo project or a collaborated one. Best of luck ahead with this knowlede guys, hope I was able to help you in your learning journey. I am Kaido and this has been a really long, but beautiful journey, Sayonara! Credits # I would like to say thanks to my friend \"Velanora\" for her help during the making of this guide, as her help allowed to tackle a really complex topic of git and GitHub which is merging PRs. So credits to her and also, she herself is a blog writer and documents her learning journey so you can checkout her blogs at \"Velanora Blogs\". ","date":"12 June 2026","externalUrl":null,"permalink":"/posts/git-and-github/","section":"Posts","summary":"","title":"Git \u0026 GitHub Pro Guide","type":"posts"},{"content":"","date":"12 June 2026","externalUrl":null,"permalink":"/","section":"Kaido Blogs","summary":"","title":"Kaido Blogs","type":"page"},{"content":"","date":"12 June 2026","externalUrl":null,"permalink":"/posts/","section":"Posts","summary":"","title":"Posts","type":"posts"},{"content":" Introduction # Let's start with who I am and what's my intention with this blog. Bio # Though I go by the name of \"Kaido\" on some of my socials, my real name is actually \"Muhammad Hasnain\". I am currently living at \"Peshawar, Pakistan\" and persuing a career in Artificial Intelligence. Having an extreme interest in programming and problem solving, I have strong ties with developing code logics. Education # I am an undergraduate in Bacheler's of Artificial Intelligence at FAST University, though you might know it as: National University of Computer and Emerging Sciences (NUCES) Skills # Through the course of my journey in tech till now, I have gotten my hand on some neat programming languages, web-development tools and skills like : C C++ HTML/CSS Graphic Design I think judging by all of this till now you might already be able to tell that most of the time, I will be seen around my laptop, and around my friends as well, which are also explorers like me. Yup, that's most of my circle. Purpose Of Kaido Blogs # Now coming to my intension with this site, since I am really fond of getting my hands on new skills and tech tools, learning how they work and what sort of stuff you can achieve using them, I thought of sharing my journey of these experiences in case it might make it easier for someone out there to do the same things that I have done. Knowledge is useless if it's confined to yourself. It's best to grow along with others and let others grow with you as well. I can't count the amount of times I have been helped out from various blogs so now when I have something in my skillbox, I think it's best to contribute my part to the community as well. Miscellaneous # Apart from all this tech interest, I am into various activities like sketching, sports, gaming and much more, although these aren't really related to this site but yeah that's all about me for now, maybe in future I will have more to say about myself but till then, take care and have a nice day. ","date":"20 March 2026","externalUrl":null,"permalink":"/aboutme/","section":"Kaido Blogs","summary":"","title":"About Me","type":"page"},{"content":" Introduction # Hey there! since you are a beginner trying to install Arch Linux in your system for probably the first time, I will guide you through this process step by step and keep it as simplistic for you as possible. Keep in mind that this guide is aimed towards installing Arch as your only OS on the system and not for dual booting Arch along with your existing OS. Now then, let's begin the process. Download Pre-Requisites # So in order to install arch linux, we need three main components to begin:\nArch Linux iso Rufus / Balena Etcher ( I will use rufus here ) A USB Arch Iso # So first let's download the arch linux iso from its official site \"Arch Linux Site\" Go to this site and scroll down to the download links section. There will be alot of options for servers to download from, servers section should look like this: I have provided a small screenshot but this list will be quiet long in reality. Now select the closest server to you for the best download speed. You will be shown a screen with several download links of Arch Linux, click the iso link as shown: After this, your Arch iso will start downloading, now let's go on to rufus. Rufus # Rufus is a software used for creating a bootable USB, which we need to install arch from. Now in order to download rufus, let's go to the official rufus site \"Rufus Site\". Then scroll down to the download section and select any of the executables: After this, rufus will start downloading in your system. Create Bootable USB # After downloading the Arch iso and rufus, it's time to create a bootable USB. So start by plugging in your USB to the system. Now go to the folder where rufus was downloaded and launch the rufus exe file. Rufus Setup # Rufus will open a new window asking to fill the parameters for creating the bootable USB for your system, it will require fields such as the USB you want to work on and the iso you want to use. So select your plugged USB drive. Then for the second field which says (Boot selection), click on the select button on the right and look for the arch iso you downloaded previously. Select the arch iso and confirm it. After these two, you will be left with Partition Scheme and Target System, select GPT for partition scheme and UEFI for target system. Now go to the Volume label field and give your USB a name like \"ArchInstallationUSB\". Leave the remaining options as it is. By the end of this whole setting process, your rufus should look a bit like this: Your Device (USB) might be different than mine so it's ok if your selection appears a bit different. After doing all this, click start button on the bottom to start creating bootable USB. Now wait as this process will take a few minutes. When it says \"Ready\", congratulations! your bootable USB is ready to go. Boot Into Arch USB # Now that your USB is ready, we need to boot into it by doing three main steps: Change Boot Sequence Turn Off Secure Boot Turn Off Raid All three of these are done from the bios of our system, so we need to begin by going to the bios. For this process we will need to restart our system and from this point onward, we will not be returning to our desktop untill the Arch Linux has finished installing. Since Arch installation will wipe the disk clean, I would suggest you should backup the data from your disk onto another device or USB if it's important to you because otherwise, it will all be lost. After you are done with this, let's continue with the bios setup. Change Boot Sequence # So restart your system and keep pressing the bios setup key depending on your system, (Mostly it is Esc/F2/F12). After entering the bios setup we need to look for boot sequence setting. Now since bios is a sensitive part of your system where you should not play with settings that you dont know about, I would suggest searching on google about how to change boot sequence of your system with your respective model name since it is different for each system, however upon searching with your model name it will show up quiet easily. Upon finding your boot sequence setting, make sure that your ArchInstallationUSB is at the top of the list, if not then bring it to the top and apply changes to the bios. Turn Off Secure Boot # Now look for another setting called \"Secure Boot\", it will also be located in the boot settings of your bios. In order to make sure that Arch installation goes smoothly, \"Secure Boot\" should be disabled. Upon finding \"Secure Boot\" in your bios setup, disable it. Turn Off Raid # Now the final step before our Arch USB can be booted, we need to turn off \"Raid\", if \"Raid\" is enabled then sometimes the Arch USB will not be able to detect our Hard Drive at the time of disk configuration. Just like the \"Secure Boot\", the \"Raid\" option will also be located in your boot options. Upon finding it, turn of \"Raid\" and turn on \"AHCI\". After doing all this, we are ready to boot into our USB. Now confirm your changes and exit the bios, your system will automatically restart and if you have followed along with me correctly upto this point, you will be greeted by arch install USB as your bootable option as shown here: Use your arrow keys to select the first option as shown in this screenshot. Hit enter and wait for the system to boot into the Arch USB. Arch Installation # Now we are going to dive into the actual installation process of Arch Linux on our system. By now you should be on a command line interface and the system should be waiting for you to start entering the commands. First of all let's clear the screen to not be disturbed by all the pre-existing text, for this press \"Ctrl + L\", this will clear the terminal anytime of all the text. Now follow each command precisely to not face any difficulties during the installation. Connect To Internet # We will need to install alot of pakages for our Arch Linux so we will need an internet connection. Let's check if we have one already by typing in our first command: ping google.com If you start receiving data packets then it means you have an internet connection established so skip to Sync System Packages, but if you receive an error message \"Temporary Failure in name resolution\", then type in the following command: iwctl This command is basically is our gateway to the internet. After running this command, we will enter the iwctl CLI (command line interface). Then we need to check our NIC (Network Interface Card). So now type the following: device list This will display the NIC of your system, for me it's wlan0 (your's might be something similar). Let's access more info about our NIC by running the next command, (replace wlan0 with your displayed NIC name): device wlan0 show You will get some additional info about you NIC. After this, we need to run our next command. So type the following command to get a list of all the networks on our NIC, (replace wlan0 with your own NIC name): station wlan0 get-networks This will give us the list of the wifi networks that are detected by our NIC. Now my wifi is called \"HUAWEI-4bxW\", so I will type the connect command next, (replace wlan0 and the wifi name with your own): station wlan0 connect HUAWEI-4bxW Terminal will prompt you to enter your wifi password, so enter your password (it will appear as *s on the screen like): Passphrase: ********* Hit the enter to confirm the password. If you dont see any output then you did it correctly. Now type in the exit command to leave iwctl: exit Now try the \"ping google.com\" command again to check if internet is connected correctly, this time you will start receiving data packets perfectly. Upnext is the syncronization of system pakages. Sync System Packages # Now we need to synchronize system packages. For this, we will run the following command: pacman -Sy After the above command finishes, run the following command: pacman -Syy By the time this command completes, your system packages should be synchronized. Now after this, we need to format the Drive and remove existing partitions. Format Disk # Clear the screen using \"Ctrl+L\". Now let's start formatting the disk. Type the following command to display the list of your disk partitions: lsblk It should look something like: Now from this list, identify your Drive that you need to install Arch on by looking at its size, and check its label, mine is \"sda\". So I will now need to format \"sda\". Your list might look totally different if you were previously running a difference OS. Either way, let's start formatting this drive. Type in the command to start the formatting process, (replace sda with your own disk): gdisk /dev/sda Now when it asks for \"Command(? for help):\", press \"x\" and hit enter. Then it will ask for \"Expert command(? for help):\", press \"z\" and hit enter again. Now it will ask for confirmation about wiping out the GPT on the drive. Press \"y\" or \"Y\" and hit enter. Lastly it will ask for confirmation about blanking out the MBR as well, press \"y\" of \"Y\" again and hit enter again. At this point, your drive will be free of any partitions and should be ready to install Arch on. You can confirm the formatting by typing in the \"lsblk\" command again. Setup Arch Install Script # Now after all this, type in the following command to check the authenticity and integrity of the Arch Linux packages, this command makes sure that the packages are from trusted sources before installation: pacman -Sy archlinux-keyring After verifying the integrity of the packages, we need to setup the Arch install script. This can be done by typing in the following command: pacman -Sy archinstall It will ask you for confirmation, press \"y\" of \"Y\" and hit enter to confirm. Now we need to launch the Arch install script to initiate system configuration for Arch Linux. For this, type in the following command: archinstall System Configuration # After running the \"archinstall\" command, you should now be on the system configuration menu of the Arch installer. Let's start configuring our installer. First setting will be the \"Language\", set it to your preferred language. Then leave the \u0026ldquo;Mirrors\u0026rdquo; untouched. \u0026ldquo;Locales\u0026rdquo; is used to setup your keyboard layouts and by default it will be US keyboard so I will leave it at that, you can change it if you want to.\nThird will be the \u0026ldquo;Disk configuration\u0026rdquo;, hit enter to go into the disk configuration. Then go into \u0026ldquo;Partitioning\u0026rdquo;. Since this a guide for beginners let\u0026rsquo;s go for the easiest option and select \u0026ldquo;Use a best-effort default partition layout\u0026rdquo;. In this, Arch itself makes the simplest disk partition to setup its boot swap and remaining parition. Otherwise we would have to do that manually. Now select the drive where you want to install Arch by using arrow keys, for me it is /dev/sda. Press tab-key or space-bar on the drive to select it, hit enter. Then choose the btrfs file-system from the displayed menu, confirm by selecting \u0026ldquo;yes\u0026rdquo;. Then select the \u0026ldquo;Use compression\u0026rdquo; from the displayed menu. Now select back to get back to main menu.\nNext is the \u0026ldquo;Bootloader\u0026rdquo;, go into it and select Grub as your bootloader.\nThen there is \u0026ldquo;Swap\u0026rdquo;, set it to true.\nSet the \u0026ldquo;Hostname\u0026rdquo; as your liking. For now, let\u0026rsquo;s go with \u0026ldquo;MyComputer\u0026rdquo;.\nNow go into the \u0026ldquo;Root password\u0026rdquo; to set your root password, save this password somewhere with you as this is really important for some actions with linux later on.\nThen we need to create a \u0026ldquo;User account\u0026rdquo;, go into it and select \u0026ldquo;Add a user\u0026rdquo; from the menu. Then enter a username for your user account, after that set a password for your user account (save this user password as well because you will constantly need it to login into your system after bootup). System will prompt you to select this account as superuser or sudo, select \u0026ldquo;yes\u0026rdquo;. Then select \u0026ldquo;Confirm and exit\u0026rdquo; to return to main menu.\nAfter that, there is the \u0026ldquo;Profile\u0026rdquo;. This is basically gonna be our desktop environment or you can say the \u0026ldquo;GUI\u0026rdquo; for desktop. Go into profile and select Desktop from the menu. A list of available Desktop-Environments will be displayed, you can even change this later on so for now I would suggest to select \u0026ldquo;KDE Plasma\u0026rdquo;. Now you will see a menu to select \u0026ldquo;Graphics Driver\u0026rdquo; and \u0026ldquo;Greeter\u0026rdquo;, go into \u0026ldquo;Graphics Driver\u0026rdquo; and select the driver based on your GPU, if you have an intel GPU select the \u0026ldquo;Intel (open-source)\u0026rdquo;, similary if you have AMD or NVIDIA GPU then select the respective driver. Then go into \u0026ldquo;Greeter\u0026rdquo; and select \u0026ldquo;sddm\u0026rdquo; as your greeter. Now go back to main menu.\nNow go into \u0026ldquo;Audio\u0026rdquo; and select \u0026ldquo;Pipewire\u0026rdquo; as your audio server and return to main menu.\nThen we have \u0026ldquo;Kernal\u0026rdquo;, you can install additional Kernals from here if you want but these are not neccessary so just skip it for now.\nThen we have the \u0026ldquo;Additional Packages\u0026rdquo;, you can install these packages after installation according to your need so for now skip this as well.\nNow we are on \u0026ldquo;Network configuration\u0026rdquo;. Go into it and select the \u0026ldquo;NetworkManager\u0026rdquo; and return to the main menu.\nAt last, we need to select the \u0026ldquo;Timezone\u0026rdquo;, now this is gonna be different for you depending on where you live, so search on google for your timezone and select it from the menu here, now return to the main menu.\nAt this point we are done with our system configuration so make sure that you have selected everything correctly before going ahead. Also, after doing disk configuration, you might be getting another option called \u0026ldquo;Disk encryption\u0026rdquo; after it, ignore it. If everything else seems fine then go to the bottom of main menu and select \u0026ldquo;Install\u0026rdquo;, it will ask for confirmation, hit enter to confirm, you will see a countdown and Arch Linux will take the wheel for a while now. This will take some time to setup and install everything so go and have a coffee or something untill it\u0026rsquo;s done.\nPost Installation Steps # Congratulations! by now, you have successfully installed Arch Linux in your system so give yourself a pat on the back since this has been a hard journey up untill now. The only thing left is to perform some post installation steps to make the system usable as a daily driver so let's continue, by now your screen should have a prompt asking you \"chroot into newly created installation and perform post-installation configuration?\". Select \"yes\". Let's run a basic command again to make sure everything is upto par. Type in the following command: pacman -Sy After this finishes up, let's download some basic softwares that we will need for our daily use such as a browser and some other stuff. For this, run the following command: pacman -Sy firefox libreoffice-fresh power-profiles-daemon vlc The system will ask you for confirmation, press \"y\" or \"Y\" to confirm. Now wait while these packages get installed, since there are multiple softwares, this will take a while. After this is done, type in the following command to exit chroot:\nexit Now we are done with the installation and setup so we need to restart our system and boot into our Hard Drive instead of the USB, so type in the following command to shutdown the system: shutdown now Now unplug the USB and start your system. If the system fails to load your Hard Drive, just go into bios again and edit the boot sequence to make sure that the Hard Drive is at the top of list, then apply and exit to boot into your Drive. You will be greeted with the grub bootloader menu: Select \"Arch Linux\" and hit enter. You should now be on the login screen, enter your user account password that you had setup during the system configuration to login. Welcome to the Desktop, you have successfully installed Arch Linux in your system. You can open the terminal by pressing \"Ctrl+Alt+T\", have fun learning the Arch commands now. Thank you for reading my blog, hope it helped. I am Kaido and this has been a beautiful journey, Sayonara! ","date":"19 March 2026","externalUrl":null,"permalink":"/posts/arch-beginner-setup/","section":"Posts","summary":"","title":"Arch Linux Beginner Setup","type":"posts"},{"content":"","externalUrl":null,"permalink":"/authors/","section":"Authors","summary":"","title":"Authors","type":"authors"},{"content":"","externalUrl":null,"permalink":"/categories/","section":"Categories","summary":"","title":"Categories","type":"categories"},{"content":"","externalUrl":null,"permalink":"/series/","section":"Series","summary":"","title":"Series","type":"series"},{"content":"","externalUrl":null,"permalink":"/tags/","section":"Tags","summary":"","title":"Tags","type":"tags"}]