{"flag":true,"single":true,"pageTitle":"Basic GitHub tutorial for developers","post":{"id":118,"user_id":"1","slug":"basic-github-tutorial-for-developers-bhdl","title":"Basic GitHub tutorial for developers","body":"<h1 style=\"text-align: center;\">Git and GitHub Tutorial for Beginners<\/h1>\r\n<p>Starting with Git can feel confusing at first, but once you understand a few core commands, it becomes one of the most useful tools for managing code. This guide explains Git and GitHub in a simple way, with clear examples you can follow step by step.<\/p>\r\n<h2>What is Git<\/h2>\r\n<p>Git is a version control system. It helps you track changes in your code over time.<\/p>\r\n<p>You can use Git to:<\/p>\r\n<ul>\r\n<li>save code history<\/li>\r\n<li>see what changed<\/li>\r\n<li>go back to older versions<\/li>\r\n<li>work safely with other developers<\/li>\r\n<li>avoid overwriting each other&rsquo;s code<\/li>\r\n<\/ul>\r\n<h2>What is GitHub<\/h2>\r\n<p>GitHub is a website where developers store and manage Git repositories online.<\/p>\r\n<p>Git does the tracking on your computer. GitHub gives you an online place to keep the project, share it, and collaborate with others.<\/p>\r\n<h2>Basic Terms You Should Know<\/h2>\r\n<h3>Repository<\/h3>\r\n<p>A repository, or repo, is your project folder that Git tracks.<\/p>\r\n<h3>Commit<\/h3>\r\n<p>A commit is a saved snapshot of your changes.<\/p>\r\n<h3>Branch<\/h3>\r\n<p>A branch is a separate line of work. You can build a feature in a branch without touching the main code.<\/p>\r\n<h3>Clone<\/h3>\r\n<p>Clone means downloading a GitHub repository to your computer.<\/p>\r\n<h3>Push<\/h3>\r\n<p>Push means sending your local commits to GitHub.<\/p>\r\n<h3>Pull<\/h3>\r\n<p>Pull means getting the latest updates from GitHub to your computer.<\/p>\r\n<h3>Staging<\/h3>\r\n<p>Staging means preparing files before making a commit.<\/p>\r\n<h2>Git File Status<\/h2>\r\n<p>When you work with files in Git, they usually appear in one of these states:<\/p>\r\n<ul>\r\n<li><strong>Untracked<\/strong> = new file that Git is not tracking yet<\/li>\r\n<li><strong>Modified<\/strong> = tracked file has been changed<\/li>\r\n<li><strong>Staged<\/strong> = file is ready to be committed<\/li>\r\n<li><strong>Unmodified<\/strong> = no changes made since the last commit<\/li>\r\n<\/ul>\r\n<h2>Step 1: Install Git on Windows<\/h2>\r\n<p>First, install Git on your computer.<\/p>\r\n<ol>\r\n<li>Open your browser<\/li>\r\n<li>Go to <strong>https:\/\/git-scm.com\/downloads<\/strong><\/li>\r\n<li>Download Git for Windows<\/li>\r\n<li>Run the installer<\/li>\r\n<li>Complete the installation with default settings<\/li>\r\n<\/ol>\r\n<p>After installing, open Command Prompt, PowerShell, or Git Bash and check the version:<\/p>\r\n<pre><code>git --version<\/code><\/pre>\r\n<p>If Git is installed correctly, you will see the installed version.<\/p>\r\n<h2>Step 2: Configure Git for the First Time<\/h2>\r\n<p>Before using Git, set your name and email. This information is attached to your commits.<\/p>\r\n<pre><code>git config --global user.name \"RIZWAN AKHTAR\"\r\ngit config --global user.email \"rizikmw@gmail.com\"<\/code><\/pre>\r\n<p>To view your saved Git configuration:<\/p>\r\n<pre><code>git config --list<\/code><\/pre>\r\n<p><strong>Tip:<\/strong> Use the same email that you use on GitHub if you want your commits linked to your GitHub account.<\/p>\r\n<h2>Step 3: Clone a Repository from GitHub<\/h2>\r\n<p>If a project already exists on GitHub, you can download it to your local machine using <strong>git clone<\/strong>.<\/p>\r\n<pre><code>git clone &lt;repository-link&gt;<\/code><\/pre>\r\n<p>Example:<\/p>\r\n<pre><code>git clone https:\/\/github.com\/RizwanKMW\/reviewsfunda.git<\/code><\/pre>\r\n<p>This command creates a copy of the project on your computer.<\/p>\r\n<h2>Step 4: Check Repository Status<\/h2>\r\n<p>You can check the current state of your project files with:<\/p>\r\n<pre><code>git status<\/code><\/pre>\r\n<p>This command shows:<\/p>\r\n<ul>\r\n<li>which files changed<\/li>\r\n<li>which files are staged<\/li>\r\n<li>which files are not being tracked yet<\/li>\r\n<\/ul>\r\n<h2>Step 5: Add Files to Staging<\/h2>\r\n<p>Before saving changes in Git, you need to add them to the staging area.<\/p>\r\n<h3>Add one specific file<\/h3>\r\n<pre><code>git add index.html<\/code><\/pre>\r\n<h3>Add all changed files<\/h3>\r\n<pre><code>git add .<\/code><\/pre>\r\n<p><strong>Example:<\/strong> If you edited <strong>index.html<\/strong> and <strong>style.css<\/strong>, then <strong>git add .<\/strong> will stage both files.<\/p>\r\n<h2>Step 6: Commit Changes<\/h2>\r\n<p>After staging files, save them with a commit.<\/p>\r\n<pre><code>git commit -m \"Add initial files\"<\/code><\/pre>\r\n<p>A good commit message should clearly explain what changed.<\/p>\r\n<p>Examples of better commit messages:<\/p>\r\n<ul>\r\n<li>Add login page<\/li>\r\n<li>Fix contact form validation<\/li>\r\n<li>Update homepage content<\/li>\r\n<\/ul>\r\n<h2>Step 7: Push Code to GitHub<\/h2>\r\n<p>After committing locally, send your changes to GitHub using:<\/p>\r\n<pre><code>git push origin main<\/code><\/pre>\r\n<p>Here:<\/p>\r\n<ul>\r\n<li><strong>origin<\/strong> = remote repository name<\/li>\r\n<li><strong>main<\/strong> = branch name<\/li>\r\n<\/ul>\r\n<h2 style=\"text-align: center;\">Creating a New Git Repository from Scratch<\/h2>\r\n<p>If your project is only on your computer and not yet connected to GitHub, follow these steps.<\/p>\r\n<h3>1. Go to your project folder<\/h3>\r\n<p>Open terminal inside your project folder.<\/p>\r\n<h3>2. Initialize Git<\/h3>\r\n<pre><code>git init<\/code><\/pre>\r\n<p>This turns your folder into a Git repository.<\/p>\r\n<h3>3. Add all files<\/h3>\r\n<pre><code>git add .<\/code><\/pre>\r\n<h3>4. Make your first commit<\/h3>\r\n<pre><code>git commit -m \"Add initial files\"<\/code><\/pre>\r\n<h3>5. Connect your local project to GitHub<\/h3>\r\n<pre><code>git remote add origin &lt;repository-link&gt;<\/code><\/pre>\r\n<p>Example:<\/p>\r\n<pre><code>git remote add origin https:\/\/github.com\/username\/projectname.git<\/code><\/pre>\r\n<h3>6. Check branch name<\/h3>\r\n<pre><code>git branch<\/code><\/pre>\r\n<h3>7. Rename branch to main<\/h3>\r\n<pre><code>git branch -M main<\/code><\/pre>\r\n<h3>8. Push code to GitHub<\/h3>\r\n<pre><code>git push -u origin main<\/code><\/pre>\r\n<p><strong>Note:<\/strong> It is <strong>origin<\/strong>, not <strong>origan<\/strong>.<\/p>\r\n<h2>Understanding Branches<\/h2>\r\n<p>Branches let you work on features or fixes without affecting the main project immediately.<\/p>\r\n<p>For example, if you want to create a new feature, you can create a branch for it. Once the feature is ready, you can merge it into the main branch.<\/p>\r\n<h3>See all branches<\/h3>\r\n<pre><code>git branch<\/code><\/pre>\r\n<h3>Switch to another branch<\/h3>\r\n<pre><code>git checkout branch-name<\/code><\/pre>\r\n<h3>Create and switch to a new branch<\/h3>\r\n<pre><code>git checkout -b new-branch-name<\/code><\/pre>\r\n<h3>Delete a branch<\/h3>\r\n<pre><code>git branch -d branch-name<\/code><\/pre>\r\n<h2>Merging Branches<\/h2>\r\n<p>After finishing work in a branch, you can merge it into your main branch.<\/p>\r\n<h3>Compare differences before merge<\/h3>\r\n<pre><code>git diff branch-name<\/code><\/pre>\r\n<h3>Merge a branch into your current branch<\/h3>\r\n<pre><code>git merge branch-name<\/code><\/pre>\r\n<p><strong>Example workflow:<\/strong><\/p>\r\n<ol>\r\n<li>Create branch <strong>login-page<\/strong><\/li>\r\n<li>Work on login feature<\/li>\r\n<li>Commit changes<\/li>\r\n<li>Switch to <strong>main<\/strong><\/li>\r\n<li>Run <strong>git merge login-page<\/strong><\/li>\r\n<\/ol>\r\n<h2>Pull Latest Changes from GitHub<\/h2>\r\n<p>If another developer updated the project, or if you updated code directly on GitHub, you should pull the latest changes.<\/p>\r\n<pre><code>git pull origin main<\/code><\/pre>\r\n<p>This downloads and merges the latest changes from GitHub into your local branch.<\/p>\r\n<h2>Delete Files or Folders in Git<\/h2>\r\n<p>If you want to remove a file or folder from the repository, use:<\/p>\r\n<pre><code>git rm file.txt\r\ngit rm -r folder-name<\/code><\/pre>\r\n<p>Then commit and push:<\/p>\r\n<pre><code>git commit -m \"Remove unused files\"\r\ngit push origin main<\/code><\/pre>\r\n<h2>Undoing Changes<\/h2>\r\n<p>Beginners often make mistakes. That is normal. These commands help you undo common changes.<\/p>\r\n<h3>Discard changes in a file before staging<\/h3>\r\n<pre><code>git checkout -- index.html<\/code><\/pre>\r\n<p>This restores the file to the last committed version.<\/p>\r\n<h3>Unstage a file after git add<\/h3>\r\n<pre><code>git reset index.html<\/code><\/pre>\r\n<h3>Undo last commit but keep changes<\/h3>\r\n<pre><code>git reset --soft HEAD~1<\/code><\/pre>\r\n<h3>Undo last commit and remove changes<\/h3>\r\n<pre><code>git reset --hard HEAD~1<\/code><\/pre>\r\n<p><strong>Warning:<\/strong> The hard reset command permanently removes changes that are not saved elsewhere.<\/p>\r\n<h2>Helpful Daily Git Workflow<\/h2>\r\n<p>Here is a simple daily routine for beginners:<\/p>\r\n<ol>\r\n<li>Open project folder<\/li>\r\n<li>Run <strong>git pull origin main<\/strong><\/li>\r\n<li>Make your code changes<\/li>\r\n<li>Run <strong>git status<\/strong><\/li>\r\n<li>Run <strong>git add .<\/strong><\/li>\r\n<li>Run <strong>git commit -m \"your message\"<\/strong><\/li>\r\n<li>Run <strong>git push origin main<\/strong><\/li>\r\n<\/ol>\r\n<h2>Example Full Workflow<\/h2>\r\n<p>Here is a complete beginner example from start to finish:<\/p>\r\n<pre><code>git clone https:\/\/github.com\/username\/projectname.git\r\ncd projectname\r\ngit status\r\ngit add .\r\ngit commit -m \"Update homepage content\"\r\ngit push origin main<\/code><\/pre>\r\n<h2>How to Create a README.md File<\/h2>\r\n<p>A README.md file explains your project. It is usually the first file people read on GitHub.<\/p>\r\n<p>Basic example:<\/p>\r\n<pre><code># Project Name\r\n\r\n## Description\r\nShort details about the project.\r\n\r\n## Features\r\n- Login system\r\n- Dashboard\r\n- Contact form\r\n\r\n## Installation\r\n1. Clone the repository\r\n2. Open the project\r\n3. Run the project\r\n\r\n## Author\r\nYour name<\/code><\/pre>\r\n<h2>Best Tips for Beginners<\/h2>\r\n<ul>\r\n<li>run <strong>git status<\/strong> often<\/li>\r\n<li>write clear commit messages<\/li>\r\n<li>pull latest changes before starting work<\/li>\r\n<li>use branches for new features<\/li>\r\n<li>do not use <strong>git reset --hard<\/strong> unless you are sure<\/li>\r\n<li>practice with a test repository first<\/li>\r\n<\/ul>\r\n<h2>Common Mistakes Beginners Make<\/h2>\r\n<ul>\r\n<li>forgetting to run <strong>git add<\/strong> before commit<\/li>\r\n<li>pushing to the wrong branch<\/li>\r\n<li>editing code without pulling latest updates<\/li>\r\n<li>using unclear commit messages like <strong>update files<\/strong><\/li>\r\n<li>confusing Git with GitHub<\/li>\r\n<\/ul>\r\n<h2>Quick Command Summary<\/h2>\r\n<pre><code>git --version\r\ngit config --global user.name \"Your Name\"\r\ngit config --global user.email \"youremail@example.com\"\r\ngit config --list\r\n\r\ngit clone &lt;repository-link&gt;\r\ngit status\r\ngit add .\r\ngit add index.html\r\ngit commit -m \"Your message\"\r\ngit push origin main\r\ngit pull origin main\r\n\r\ngit init\r\ngit remote add origin &lt;repository-link&gt;\r\ngit branch\r\ngit branch -M main\r\ngit checkout branch-name\r\ngit checkout -b new-branch-name\r\ngit branch -d branch-name\r\ngit diff branch-name\r\ngit merge branch-name\r\n\r\ngit rm file.txt\r\ngit rm -r folder-name\r\n\r\ngit reset index.html\r\ngit reset --soft HEAD~1\r\ngit reset --hard HEAD~1<br><br>xd<br><br><\/code><\/pre>\r\n<p style=\"text-align: center;\"><strong>How to clone private repositories to remote servers ie Github -&gt; namecheap<\/strong><\/p>\r\n<p><strong>1. In namecheap generate keys using below command<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>ssh-keygen -t ed25519 -C \"server-deploy\"<\/code><\/pre>\r\n<p>This creates two files:&nbsp;~\/.ssh\/id_ed25519 ,&nbsp;~\/.ssh\/id_ed25519.pub<\/p>\r\n<p><strong>2. Copy the public key<\/strong><br>cat ~\/.ssh\/id_ed25519.pub<\/p>\r\n<p><strong>3.Goto below directory and paste the public keys there<\/strong><br>GitHub &rarr; Settings &rarr; SSH and GPG Keys &rarr; New SSH Key<\/p>\r\n<p><strong>4. Goto namecheap terminal and paste below command<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>git clone git@github.com:USERNAME\/REPOSITORY.git #this will clone zip source code<\/code><\/pre>\r\n<p>to clone direct files use below commands<\/p>\r\n<pre class=\"language-markup\"><code>cd ~\/public_html\r\ngit init\r\ngit remote add origin git@github.com:USERNAME\/REPOSITORY.git\r\ngit pull origin main<\/code><\/pre>\r\n<p>&nbsp;<\/p>\r\n<p><strong>5. Deploy updates from GitHub<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>git pull origin main<\/code><\/pre>\r\n<h2>DOWNLOAD LATEST CODE FROM GITHUB TO LOCAL<\/h2>\r\n<pre class=\"language-markup\"><code>git fetch origin\r\ngit reset --hard origin\/main<\/code><\/pre>\r\n<h2>Final Words<\/h2>\r\n<p>Git and GitHub may look technical in the beginning, but the basics are actually simple once you practice them. Start with cloning, checking status, adding files, committing, pulling, and pushing. After that, learn branches and merging. With regular use, these commands will become part of your normal coding workflow.<\/p>","category_id":"18","is_private":"0","created_at":"2023-04-14T02:27:37.000000Z","updated_at":"2026-04-04T00:44:32.000000Z","category":{"id":18,"user_id":"1","name":"Tutorials","slug":"tutorials-n3lw","parent_id":null,"created_at":"2023-04-01T17:24:32.000000Z","updated_at":"2023-04-01T17:24:32.000000Z"},"user":{"id":1,"name":"R GONDAL","email":"rizikmw@gmail.com","email_verified_at":null,"two_factor_confirmed_at":null,"current_team_id":"1","profile_photo_path":null,"created_at":"2023-03-12T10:49:33.000000Z","updated_at":"2025-01-10T12:59:00.000000Z","profile_photo_url":"https:\/\/ui-avatars.com\/api\/?name=R+G&color=7F9CF5&background=EBF4FF"}},"pageDesc":"Git and GitHub Tutorial for Beginners Starting with Git can feel confusing at first, but once you understand a few core commands, it becomes - Basic GitHub tutorial for developers (Updated: April 4, 2026) - Read more about Basic GitHub tutorial for developers at my programming site [SITE]","categories":[]}