ls -al ~/.ssh # # generate ssh key # ssh-keygen -t rsa -C "email@work_mail.com" -f "id_rsa_work_user1" # #Adding the new SSH key to the corresponding GitHub account # #Copy the public key pbcopy < ~/.ssh/id_rsa.pub #and then log in to your personal GitHub account: 1 Go to Settings 2 Select SSH and GPG keys from the menu to the left. 3 Click on New SSH key, provide a suitable title, and paste the key in the box below 4 Click Add key — and you’re done! # #Registering the new SSH Keys with the ssh-agent # ssh-add ~/.ssh/id_rsa_work_user1 #in case ssh agent is not open exec ssh-agent bash #--------------------------------------------------------------------- #Creating the SSH config File #--------------------------------------------------------------------- cd ~/.ssh/ touch config // Creates the file if not exists code config // Opens the file in VS code, use any editor # Personal account, - the default config Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa # Work account-1 Host github.com-work_user1 HostName github.com User git IdentityFile ~/.ssh/id_rsa_work_user1 #---------------------------------------------------------------------- # #Clone repo # git clone git@github.com-work_user1:work_user1/repo_name.git # #For Locally Existing Repositories #If we have the repository already cloned: #List the Git remote of the repository: git remote -v #Check whether the URL matches our GitHub host to be used, or else update the remote origin URL. git remote set-url origin git@github.com-worker_user1:worker_user1/repo_name.git #Ensure the string between @ and : matches the Host we have given in the SSH config. # #If you are creating a new repository on local, initialize Git in the project folder: git init #Create the new repository in the GitHub account and then add it as the Git remote to the local repository. git remote add origin git@github.com-work_user1:work_user1/repo_name.git git remote set-url origin git@github_mdcdev:mdcdev/mdc_sid_web.git #Ensure the string between @ and : matches the Host we have given in the SSH config. #VSCode: command-shif-p git@github_k4zek4ge:k4zek4ge/insta.git #Push the initial commit to the GitHub repository: git add . git commit -m "Initial commit" git push -u origin master