Monday, October 13, 2025

Github repo

GITHUB INITIALIZATION OR NEW GITHUB push 

 # ✅ Step 1: Check if Git is installed

git --version


# ✅ Step 2: Configure your Git identity

git config --global user.name "Your Name"

git config --global user.email "youremail@example.com"


# ✅ Step 3: Go to your project directory

cd path/to/your/project


# ✅ Step 4: Initialize git

git init


# ✅ Step 5: Create .gitignore file (optional but recommended)

echo "*.pyc

__pycache__/

.env

venv/

*.sqlite3

" > .gitignore


# ✅ Step 6: Add all files to staging

git add .


# ✅ Step 7: Commit your code

git commit -m "Initial commit"


# ✅ Step 8: Connect to your GitHub repository (replace the URL)

git remote add origin https://github.com/yourusername/your-repo.git


# ✅ Step 9: Rename main branch and push

git branch -M main

git push -u origin main


# ✅ Step 10: Verify connection

git remote -v

----------------------------------------------------------------------------------------
--------------------- Github push failing reason and resolution ---------------
# ๐Ÿงฉ Check Git installation
git --version

# ๐Ÿงฐ Set up Git identity
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"

# ๐Ÿ“‚ Move into your project directory
cd path/to/your/project

# ๐Ÿ—️ Initialize Git if not already done
git init

# ๐Ÿงพ Create .gitignore (optional but recommended)
echo "*.pyc
__pycache__/
.env
venv/
*.sqlite3
" > .gitignore

# ➕ Add all files to staging
git add .

# ๐Ÿ’ฌ Commit your code
git commit -m "Initial commit"

# ๐Ÿ”— Set or reset remote repository (replace with your actual repo URL)
git remote remove origin 2> /dev/null
git remote add origin https://github.com/yourusername/your-repo.git

# ๐ŸŒฟ Rename branch to main
git branch -M main

# ๐Ÿงช Verify remote
git remote -v

# ๐Ÿš€ Try pushing your code
git push -u origin main

# ๐Ÿงฑ If push fails due to authentication, generate a Personal Access Token:
#    1. Visit https://github.com/settings/tokens
#    2. Generate new token (classic) with "repo" and "workflow" permissions
#    3. Use your GitHub username, and the token as your password when prompted

# ๐Ÿ’พ Save credentials so Git remembers them
git config --global credential.helper store

# ๐Ÿ› ️ If the repo already has commits (like a README), pull first:
git pull origin main --rebase
git push -u origin main

# ๐Ÿงน If you still face branch mismatch issues
git branch -M main
git push -u origin main

# ๐Ÿ”’ If switching to SSH (optional)
# git remote set-url origin git@github.com:yourusername/your-repo.git
-----------------------------------------------------------------------------------------
********* SSH SETUp *************************************
# ๐Ÿงฉ Check if SSH is installed
ssh -V

# ✅ Generate a new SSH key (replace with your GitHub email)
ssh-keygen -t ed25519 -C "youremail@example.com"

# When asked for a file path, just press Enter to accept default
# When asked for a passphrase, you can press Enter (optional)

# ✅ Start the SSH agent
eval "$(ssh-agent -s)"

# ✅ Add your private SSH key to the agent
ssh-add ~/.ssh/id_ed25519

# ✅ Show your public key (copy this output)
cat ~/.ssh/id_ed25519.pub

# ๐Ÿ”— Go to https://github.com/settings/keys
# → Click "New SSH key"
# → Give it a title (e.g., MyLaptop)
# → Paste the copied key
# → Click "Add SSH key"

# ✅ Test SSH connection
ssh -T git@github.com

# ✅ If success: you'll see "Hi username! You've successfully authenticated..."

# ๐Ÿงฐ Now connect your local project with SSH
cd path/to/your/project

# Initialize git if not done already
git init

# Add .gitignore (optional)
echo "*.pyc
__pycache__/
.env
venv/
*.sqlite3
" > .gitignore

# Stage and commit files
git add .
git commit -m "Initial commit"

# ✅ Link your GitHub repo using SSH (replace username/repo)
git remote remove origin 2> /dev/null
git remote add origin git@github.com:yourusername/your-repo.git

# ✅ Push to GitHub
git branch -M main
git push -u origin main

# ✅ Verify remote connection
git remote -v
------------------------------------------------------------------------------
kayyum@DESKTOP-QM3A3JG MINGW64 ~
$ git config --list
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=schannel
core.autocrlf=true
core.fscache=true
core.symlinks=false
pull.rebase=false
credential.helper=manager
credential.https://dev.azure.com.usehttppath=true
init.defaultbranch=master
user.name=Kayyum Shaikh
user.email=kayyum****@gmail.com
-------------------------------------------------------------------------------

virtual environment on python on Ubuntu

 # 1. Update system and install Python tools sudo apt update && sudo apt install python3-pip python3-venv -y # 2. Setup Django in a ...