{"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;\">Gitx and GitHub Tutorial for Beginners<\/h1>\r\n<p>Git is a version control system. It helps you track changes in your code over time. GitHub is a website where developers store and manage Git repositories online.<\/p>\r\n<ul>\r\n<li>save code history || see older codes&nbsp; &gt;&gt; work safely with other developers&nbsp; &nbsp;&gt;&gt; avoid overwriting each other&rsquo;s code<\/li>\r\n<\/ul>\r\n<p><strong>Git File Status: <\/strong>When you work with files in Git, they usually appear in one of these states:<\/p>\r\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\"><colgroup><col style=\"width: 4.98891%;\"><col style=\"width: 16.0745%;\"><col style=\"width: 5.10067%;\"><col style=\"width: 21.1197%;\"><col style=\"width: 7.76053%;\"><col style=\"width: 18.1818%;\"><col style=\"width: 8.53659%;\"><col style=\"width: 18.2373%;\"><\/colgroup>\r\n<tbody>\r\n<tr>\r\n<td><strong>Untracked&nbsp;<\/strong><\/td>\r\n<td>new file that Git is not tracking yet<\/td>\r\n<td><strong>Modified&nbsp;<\/strong><\/td>\r\n<td>tracked file has been changed<\/td>\r\n<td><strong>Staged&nbsp;<\/strong><\/td>\r\n<td>file is ready to be committed<\/td>\r\n<td><strong>Unmodified&nbsp;<\/strong><\/td>\r\n<td>no changes made since the last commit<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<h2><span style=\"font-size: 12pt;\">Step 1: Install Git on Windows<\/span><\/h2>\r\n<ol>\r\n<li>Go to <strong><a href=\"https:\/\/git-scm.com\/downloads\">https:\/\/git-scm.com\/downloads<\/a><\/strong><\/li>\r\n<li>after install check version in cmd <strong>git --version<\/strong><\/li>\r\n<li>Fir time Config git as&nbsp;<\/li>\r\n<\/ol>\r\n<pre><code>git config --global user.name \"RIZWAN AKHTAR\"\r\ngit config --global user.email \"rizikmw@gmail.com\"<\/code><br>To view your saved Git configuration:<\/pre>\r\n<pre><code>git config --list<\/code><br><strong>USEFULL COMMANDS:<br><\/strong><\/pre>\r\n<table style=\"border-collapse: collapse; width: 100%; height: 111.953px;\" border=\"1\"><colgroup><col style=\"width: 2.27512%;\"><col style=\"width: 31.0397%;\"><col style=\"width: 66.6851%;\"><\/colgroup>\r\n<tbody>\r\n<tr style=\"height: 22.3906px;\">\r\n<td style=\"height: 22.3906px;\">1<\/td>\r\n<td style=\"height: 22.3906px;\"><code>git clone https:\/\/github.com\/RizwanKMW\/reviewsfunda.git<\/code><\/td>\r\n<td style=\"height: 22.3906px;\">git clone is used to clone the repositry from github to local, This command creates a copy of the project on your computer.<\/td>\r\n<\/tr>\r\n<tr style=\"height: 22.3906px;\">\r\n<td style=\"height: 22.3906px;\">2<\/td>\r\n<td style=\"height: 22.3906px;\"><code>git status<\/code><\/td>\r\n<td style=\"height: 22.3906px;\">Mofied files, staged files (only that added using git add), not tracked files<\/td>\r\n<\/tr>\r\n<tr style=\"height: 22.3906px;\">\r\n<td style=\"height: 22.3906px;\">3<\/td>\r\n<td style=\"height: 22.3906px;\"><code>git add<\/code><\/td>\r\n<td style=\"height: 22.3906px;\">to stage files, <code>git add index.php<\/code> , <code>git add .<\/code> (all changed files add to staging),&nbsp;<\/td>\r\n<\/tr>\r\n<tr style=\"height: 22.3906px;\">\r\n<td style=\"height: 22.3906px;\">4<\/td>\r\n<td style=\"height: 22.3906px;\"><code>git commit<\/code><\/td>\r\n<td style=\"height: 22.3906px;\">add a message to staged files <code>git commit -m \"Add initial files\"<\/code><\/td>\r\n<\/tr>\r\n<tr style=\"height: 22.3906px;\">\r\n<td style=\"height: 22.3906px;\">5<\/td>\r\n<td style=\"height: 22.3906px;\"><code>git push<\/code><\/td>\r\n<td style=\"height: 22.3906px;\">send changes to github <code>git push origin main<\/code> &gt;&gt; push all code to main branch you can add other branches also<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>6<\/td>\r\n<td><code>git branch<\/code><\/td>\r\n<td>Check branch name using &nbsp;<code>git branch<\/code> if want to rename it use <code>git branch -M main<\/code><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<pre><strong><span style=\"font-size: 12pt;\">Creating a New Git Repository from Scratch<\/span><\/strong><\/pre>\r\n<p>If your project is only on your computer and not yet connected to GitHub, follow these steps.<\/p>\r\n<table style=\"border-collapse: collapse; width: 100%; height: 89.5624px;\" border=\"1\"><colgroup><col style=\"width: 2.54989%;\"><col style=\"width: 30.8388%;\"><col style=\"width: 66.5559%;\"><\/colgroup>\r\n<tbody>\r\n<tr style=\"height: 22.3906px;\">\r\n<td style=\"height: 22.3906px;\">1<\/td>\r\n<td style=\"height: 22.3906px;\"><code>git init<\/code><\/td>\r\n<td style=\"height: 22.3906px;\">init This turns your folder into a Git repository.<\/td>\r\n<\/tr>\r\n<tr style=\"height: 22.3906px;\">\r\n<td style=\"height: 22.3906px;\">2<\/td>\r\n<td style=\"height: 22.3906px;\"><code>git add .<\/code><\/td>\r\n<td style=\"height: 22.3906px;\">add all files to staging status<\/td>\r\n<\/tr>\r\n<tr style=\"height: 22.3906px;\">\r\n<td style=\"height: 22.3906px;\">3<\/td>\r\n<td style=\"height: 22.3906px;\"><code>git commit -m \"Add initial files\"<\/code><\/td>\r\n<td style=\"height: 22.3906px;\">add a commit message to files<\/td>\r\n<\/tr>\r\n<tr style=\"height: 22.3906px;\">\r\n<td style=\"height: 22.3906px;\">4<\/td>\r\n<td style=\"height: 22.3906px;\"><code>git remote add origin &lt;repository-link&gt;<\/code><\/td>\r\n<td style=\"height: 22.3906px;\">connect local project with github repository ie <code>git remote add origin https:\/\/github.com\/username\/projectname.git<\/code><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<p style=\"text-align: center;\"><span style=\"font-size: 24pt;\"><strong>How to clone private repositories to remote servers ie Github -&gt; namecheap<\/strong><\/span><\/p>\r\n<ul>\r\n<li><span style=\"font-size: 12pt;\">PuTTY installed, with plink.exe on your PATH.<\/span><\/li>\r\n<li><span style=\"font-size: 12pt;\">SSH access enabled on the Namecheap hosting plan.<\/span><\/li>\r\n<li><span style=\"font-size: 12pt;\">Git installed on the Namecheap server (already included on all Namecheap plans).<\/span><\/li>\r\n<\/ul>\r\n<p><span style=\"font-size: 12pt;\">Logging into the server doesn't automatically grant it access to a private repo GitHub still needs to know who the server is.<\/span><\/p>\r\n<p>&nbsp;<\/p>\r\n<h3>Option 1: SSH deploy key (recommended)<\/h3>\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><code>cat ~\/.ssh\/id_ed25519.pub<\/code><\/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><strong>5. Deploy updates from GitHub<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>git pull origin main<\/code><\/pre>\r\n<p><span style=\"font-size: 14pt;\"><strong>Option 2: HTTPS + personal access token<\/strong><\/span><br>git clone https:\/\/&lt;username&gt;:&lt;token&gt;@github.com\/&lt;user&gt;\/&lt;repo&gt;.git<\/p>\r\n<p>&nbsp;<\/p>\r\n<div id=\"output\" class=\"content markdown-body\">\r\n<h2><code>deploy.bat<\/code><\/h2>\r\n<p>Set your own credentials at the top before using it.&nbsp;<\/p>\r\n<p><code><strong>https:\/\/raw.githubusercontent.com\/RizwanKMW\/github_deploy_script\/refs\/heads\/main\/deploy.bat<\/strong><\/code><\/p>\r\n<p>&nbsp;<\/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;\">&nbsp;<\/p>\r\n<\/div>","category_id":18,"is_private":0,"created_at":"2023-04-14T02:27:37.000000Z","updated_at":"2026-08-28T16:59:25.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":"Gitx and GitHub Tutorial for Beginners Git is a version control system. It helps you track changes in your code over time. GitHub is a websi - Basic GitHub tutorial for developers (Updated: August 28, 2026) - Read more about Basic GitHub tutorial for developers at my programming site [SITE]","categories":[]}