Monday, August 18, 2014

Git Commands

Quick Tip – Wrong SSH Key Cached With Github After Changing Users and Keys

If you find that you are unable to access Github after switching out your private keys, you may have a key cached with ssh agent. To diagnose:

ssh git@github.com -v

ssh git@github.com (and check the username or error message if any)

Kill the ssh-agent
killall ssh-agent


Add the private key of the User to the SSH-Agent.
$ ssh-add -l
The agent has no identities.
ssh-add ~/.ssh/id_rsa

Storing Passphrase's in the Keychain
To store the passphrase for your default key in the Keychain open a Terminal and run:

ssh-add -K
And to store the passphrase for a different key run:
ssh-add -K /path/to/private/key/file


Deleting a file from Git Repo
git rm file1.txt
git commit -m "remove file1.txt"


Know the Git Remote URL
git remote -v
remote set-url origin https://github.com/siddharthagit/CRS-motilecloud-14.git


Push an existing repository from the command line
git remote add origin git@github.com:siddharthagit/CRS-mobilecloud-14.git
git push -u origin master

No comments :

Post a Comment