Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Did you work on several projects? Sometimes you will also use a seperate git account for each project.

If you have trouble to get access - try this...

This example based on a linux system, but meight be comparable to other systems.

My example situation

  • I am using a Business Notebook in my professional and private projects
  • As a employee i have to use my company account on github.com
  • As a freelancer i am using my private account on github.com

Lets configure the solution of our problem

  • create (if not already done) your personal SSH Key like discribed on github.com
console
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
Generating public/private rsa key pair.
  • set "your_email@example.com" to your login mail
  • next - save the key
console
Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
  • on Linux it's ~/.ssh/ Directory and now » ~/.ssh/git_my_private_key
  • If not already done - do it twice with your business mail »  ~/.ssh/git_my_business_key

Now we need to configure your standard SSH Config:

console
~$: nano ~/ssh/config
  • you may also use vi (smile)
  • add this block on your configuration
console
# Git private Account
Host git-private
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/git_my_private_key

Do another block with your business account

console
# Git business Account
Host git-business
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/git_my_business_key

Get ready ?? Let's keep magic happen...

Save your key for SSH access in your account.

The private key at your private account.

The business key at your business account.

Login into your account, and click on "Settings".

Now, click on "New SSH key".

The name of your key is just for identification of yourself. In my case it's "HQNB14" - my business Notebook.

After you saved the key you can start managing your project.

Project settings

If you are starting with a new Project you have to clone your copy - normaly like this:

Now chance this to:

  • clone git@git-private:YOURGITHUBNAME/oc-server3.git

What happens?

Git ask you maybe for your SSH Key password. Thats all! You should now have access to your GitHub Repro.

In this case, you switched from github.com to a local HOST. This is definied in your SSH config.

This config routes your request to github.com - BUT it knows, it have to use your specified key file.

Did you alreasy cloned and need to reconfigure your settings?

Simple. In your Project directory is a .git/config file.

It contains all settings.

Change your remote origin (your own Fork):

console
[remote "origin"]
        url = git@git-private:YOURGITHUBNAME/oc-server3.git
        fetch = +refs/heads/*:refs/remotes/origin/*

So, set url to "@git-private" and your SSH config will work.

Don't forget to set your personal Info in your Project.

console
[user]
        name = YOURGITHUBNAME
        email = youremail@github
  • No labels