What is GitHub?

GitHub is a cloud-based platform for version control and collaboration using Git. It helps developers manage code, track changes, and work together on projects.

Why Use GitHub?

Simple GitHub Guide for Windows Users

To start with this tutorial make sure you have install git from this url https://git-scm.com/downloads. Install it like a game. (Just next next next...)

This will install git bash on your windows machine. Then Continue..

1. Initialize a Git Repository

To initialize a local Git repository, navigate to the project folder in the command line (git bash) , and run. 

git init

This will create a hidden .git directory, signifying the start of a Git repository, even if the folder is initially empty.

2. Configure Git User Information

git config --local user.name "Your Name"
git config --local user.email "your_email@example.com"

3. Stage Changes

Once you've initialized your Git repository, to make a snapshot you have to stage the changes by using this command.

git add . #this is stage all untracked file

4. Commit Changes

After staging all change to make a checkpoint you can make a meaning full commit to make the changes permanent.

git commit -m "Your commit message"
#example git commit -m "first commit"

5. Add a Remote Repository

6. Connect your Local Repository with  Remote Repository

When you create a remote repository you next step should be connect you repository with you local machine.

git branch M main #this rename the branch name into main
git remote add <remote_name> git@github.com:<your_github_user_name>/<your_repository_name>.git
#exmple git remote add origin git@github.com:PallabDev/git_repo_1.git

7. How to connect git with Github using ssh key 

This step is very important to do, otherwise you can't push you private repository to github.

To do so run this commands one by one: ( Make sure you run all this command in Git Bash Terminal )  

ssh-keygen -t ed25519 #remember it will ask for a path. remember that path
# press enter to choose default location.
# To Copy the SSH key go to the path using git bash or any command line 
# open the id_ed25519.pub file which you have created now.

8. The SSH key

cat id_ed25519.pub

Add SSH Key to GitHub

  1. Go to GitHub and log in.
  2. Click on your profile picture (top-right) → Settings.
  3. In the left sidebar, go to SSH and GPG keys.
  4. Click New SSH Key.
  5. Title: Enter a name (e.g., "My PC SSH Key").
  6. Key: Paste the copied SSH key.
  7. Click Add SSH Key.

9. Publish the changes into Github

git push -u origin master

10. Create and Switch Branche

git branch <branch_name> #create new branch
git checkout <branch_name> #switch to new branch

11. Delete Local Git Repository

rm -rf .git

We will update this blog soon to include version control-related commands as well. Stay Tune ✔️

 

Github for Absolute Biginners: Essential Comand you should Know