Skip to content

Instantly share code, notes, and snippets.

@codewithsanthoshofficial
Created February 24, 2026 07:20
Show Gist options
  • Select an option

  • Save codewithsanthoshofficial/bbb82f925aef697b9186201a97d7eb70 to your computer and use it in GitHub Desktop.

Select an option

Save codewithsanthoshofficial/bbb82f925aef697b9186201a97d7eb70 to your computer and use it in GitHub Desktop.
Git_Terminal_info
Amazon git
1)
Create New Repo for project Cd path
Git remote -v (check have any old paths)
rm -rf .git (if have any old paths remove)
Git remote -v (check have any old paths)
Git init .
Git remote add origin SSHkey ( SSHKey will get from aws when click on create button and enter project name then get ssh keys and https keys)
Git checkout -b dev
Git add .
Git commit -m “changes or appnames”
Git push origin dev
Done
2)
create another branch from master
git checkout -b "branchname" -> creates new branch
git branch -> lists all branches
git checkout "branchname" -> switches to your branch
git push origin "branchname" -> Pushes to your branch
git add */filename -> Stages *(All files) or by given file name
git commit -m "commit message" -> Commits staged files
git push -> Pushes to your current branch
3)
change user name
i) git checkout 3690ebcd (first clone project then specific id 3690ebcd use it)
ii) git reset --hard <hash-or-ref>
iii) Refer: https://stackabuse.com/git-revert-to-a-previous-commit/
4)
For macOS try this for https problem:
git config --global credential.helper osxkeychain
Then try pull, push and it should ask for username and password.
@codewithsanthoshofficial

codewithsanthoshofficial commented Mar 1, 2026

Copy link
Copy Markdown
Author

One-Time Setup (Only Once Per Machine)

1️⃣ Generate SSH Key
ssh-keygen -t ed12345 -C "your_email@example.com"

Press Enter to accept default path.

2️⃣ Start SSH Agent

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed12345

check : CMD: ls ~/.ssh

or
CMD: ssh-add -l
or

CMD: ssh -T git@github.com
git@github.com: Permission denied (publickey)

worked - get or generate SSH key

CMD: ls ~/.ssh
(Know your private and public key. don't share private key use public key for GitHub it like
agent id_ed12345 id_ed12345.pub known_hosts )

CMD: cat ~/.ssh/id_ed12345.pub

3️⃣ Copy Public Key
pbcopy < ~/.ssh/id_ed12345.pub

4️⃣ Add SSH Key to GitHub
Go to:
GitHub → Settings → SSH and GPG Keys → New SSH Key
Paste key → Save

5️⃣ Verify SSH Works

ssh -T git@github.com

Expected:

Hi ! You've successfully authenticated...
If this works → SSH setup is complete forever (for this machine).

final

cd project_folder
Git remote -v (check have any old paths)
rm -rf .git (if have any old paths remove)
Git remote -v (check have any old paths)
git init
git remote add origin git@github.com:username/repository.git
git add .
git commit -m "Initial commit"
git push -u origin main

@codewithsanthoshofficial

Copy link
Copy Markdown
Author

steps done: issue : git@github.com: Permission denied (publickey).

ssh-add -l

ssh-add ~/.ssh/id_ed12345

Identity added:

ls ~/.ssh

agent id_ed12345 id_ed12345.pub known_hosts

ssh-add -l

Now get SSH Key (Only Once Per Machine)

0r any issue for generate SSH KEY use this

cat ~/.ssh/id_ed25519.pub

still git@github.com: Permission denied (publickey).
above generated SSH KEY add in GitHub - generate by using public key
Add SSH Key to GitHub
Go to:
GitHub → Settings → SSH and GPG Keys → New SSH Key
Paste key → Save

pbcopy < ~/.ssh/id_ed12345.pub

ssh -T git@github.com

ssh -T git@github.com
Enter passphrase for key '/Users/.ssh/id_ed12345':
Hi l! You've successfully authenticated, but GitHub does not provide shell access.

@santhoshappdev

Copy link
Copy Markdown

Step 1 — Generate Second SSH Key (For Second Account)

ssh-keygen -t ed12345 -C "second_email@example.com"

When asked for file name, enter:

~/.ssh/id_ed12345_account2

Now you will have:
id_ed12345
id_ed12345.pub
id_ed12345_account2
id_ed12345_account2.pub

Step 2 — Add Second Public Key to Second GitHub Account

cat ~/.ssh/id_ed12345_account2.pub
Copy and add it in:
GitHub → Settings → SSH and GPG Keys → New SSH Key

Step 3 — Configure SSH Config File (Important Step)

Edit or create:
nano ~/.ssh/config

Add:

Account 1

Host github-account1
HostName github.com
User git
IdentityFile ~/.ssh/id_ed12345

Account 2

Host github-account2
HostName github.com
User git
IdentityFile ~/.ssh/id_ed12345_account2
Save and exit.

Step 4 — Use Correct Remote URL Per Project

For Account 1 repo:
git remote add origin git@github-account1:username/repo.git
For Account 2 repo:
git remote add origin git@github-account2:username/repo.git
Notice:
github-account1
github-account2
These match the Host names in SSH config.

Step 5 — Test

ssh -T git@github-account1
ssh -T git@github-account2
Each should authenticate to correct account.

✅ Alternative (Official Option)

GitHub also allows using HTTPS with Personal Access Token (PAT) instead of SSH.
Documented by GitHub (2021 security update).
But SSH with config separation is cleaner for developers.

@codewithsanthoshofficial

Copy link
Copy Markdown
Author

First account
Run:
ssh-keygen -t ed25519 -C "codewithsanthosh.offical@gmail.com"

When prompted:
Enter file in which to save the key
Paste EXACTLY:
/Users/konetisanthoshkumar/.ssh/github_main
NOT:
/.ssh/github_main
"
/.ssh/github_main"

Second account
Run:
ssh-keygen -t ed25519 -C "likildikil@gmail.com"
Then enter:
/Users/konetisanthoshkumar/.ssh/github_second

Expected Success Output
You should finally see:
Your identification has been saved in ...
Your public key has been saved in ...
Verify
Run:
ls -la ~/.ssh
Expected:
github_main
github_main.pub
github_second
github_second.pub
known_hosts
Then Continue

Add keys to ssh-agent
ssh-add /Users/konetisanthoshkumar/.ssh/github_main
ssh-add /Users/konetisanthoshkumar/.ssh/github_second
Show public keys
First:
cat /Users/konetisanthoshkumar/.ssh/github_main.pub
Second:
cat /Users/konetisanthoshkumar/.ssh/github_second.pub

enter above cmd into terminal get keys

Add each to the correct GitHub account at:
GitHub SSH Key Settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment