Git and github
github
Fix GitHub Push Error using SSH
If git push fails with Repository not found, switch from HTTPS to SSH.
Steps:
Check for an existing SSH key:
ls ~/.ssh→ ifid_ed25519exists, reuse it.Generate a key (if needed):
ssh-keygen -t ed25519 -C "shaikuzma2023@gmail.com"Start SSH agent & add key:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519Copy public key:
pbcopy < ~/.ssh/id_ed25519.pubAdd key to GitHub → Settings → SSH and GPG keys.
Test connection:
ssh -Tgit@github.com→ should authenticate successfully.Change repo remote to SSH:
git remote set-url origingit@github.com:uzma-dev/Portfolio.gitPush code:
git push -u origin main
Why this works:
HTTPS needs credentials/tokens. SSH uses key-based authentication—clean, secure, and password-free.
git
create a new repository on the command line
echo "# Portfolio" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/uzma-dev/Portfolio.git
git push -u origin main
OR push an existing repository from the command line
git remote add origin https://github.com/uzma-dev/Portfolio.git
git branch -M main
git push -u origin main
git push -u origin main
Pushes your local
mainbranch to the remote repoorigin(GitHub).-usets an upstream link between localmainandorigin/main.After this, you can use just
git pushorgit pullwithout extra arguments.Usually run once per branch.
to create a new branch :
git checkout -b feature-branch-name
or new syntax
git switch -c feature-branch-name
after that add commit and push the new branch git push -u origin feature-branch-name.