User Tools

Site Tools


en:cs:git:basic:multipleaccount

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:cs:git:basic:multipleaccount [2025/05/03 20:43] – created ulascemhen:cs:git:basic:multipleaccount [2025/05/04 18:46] (current) – removed ulascemh
Line 1: Line 1:
-====== Using Multiple Githup Accounts on One Computer ====== 
  
-I am writing for the Windows operating system, but the logic should work for other operating systems as well. With 5 simple steps we will be able to switch between accounts whenever we want. 
- 
-  - Generate SSH keys for all accounts 
-  - Adding SSH keys to SSH Agent 
-  - Adding SSH public keys to Githup 
-  - Creating setting file and preparing Host inputs 
-  - Using different accounts when copying Githup repos 
- 
-===== Generating SSH Keys for all accounts ===== 
- 
-For Windows, you need to be in the user folder. But we don't need to worry about that since we will use the Git Bash command line. We can get things done using Unix code. 
- 
-<code> 
-C:\Users\__SENIN_KULLANICI_ADIN__\ 
-</code> 
- 
-  - Open Git Bash and type the following codes in order. 
- 
- 
-<code bash> 
-cd ~ 
-mkdir .ssh 
-# If the folder already exists, the above will give an error. If it already exists, we will use that folder. 
-cd .ssh 
-eval `ssh-agent -s` 
-</code> 
- 
-  - Create ssh keys for each account in the relevant folder using the following code. 
- 
-<code bash> 
-ssh-keygen -t rsa -C "__MAIL_ADDRESS__" -f "__GITHUP_USER_NAME__" 
-</code> 
- 
-<WRAP round info> 
-The ''%%-C%%'' key here is for comments to help with identification. ''%%-f%%'' is the name of the file where the key will be saved. 
-</WRAP> 
- 
-<WRAP round important> 
-**Dikkat**: Burada yazacağın mail adresinde githup'ın bize tanımladığı mail atılamaz mail adresi olmalıdır. Zorunlu değil ancak asıl mail adresimizi karışıklık olmaması için giçbir git işleminde kullanmamak daha iyidir. 
-</WRAP> 
- 
-<WRAP center round info 60%> 
-Anahtarları ekledikten sonra **.ssh** klasörü içerisinde her hesap için bir private bir public dosya oluşması lazım. 
- 
-Public anahtar ''%%.pub%%'' uzantısına sahip olacak ve private anahtar ise bir uzantıya sahip olmayacaktır. İkisininde ismi ''%%-f%%'''den sonra yazdığınla aynı olacaktır. 
- 
-Tüm hesapların için birer anahtar oluşturduktan sonra devam edebilirsin. 
- 
-</WRAP> 
- 
-===== SSH Anahtarlarının SSH Agent'a Eklenmesi ===== 
- 
-Komut satırında hâla .ssh içerisindeyken aşağıdaki komutla anahtarları agent'a ekleyebilirsin. 
- 
-<code bash> 
-ssh-add __GITHUP_KULLANICI_ADI__ 
-ssh-add __GITHUP_KULLANICI_ADI__ 
-</code> 
- 
-===== SSH Public Anahtarının Githup'a Eklenmesi ===== 
- 
-Oluşan ''.pub'' dosyalarını herhangi bir metin editörü ile aç ve içeriğini kopyala. 
- 
-[[https://github.com/settings/keys|https://github.com/settings/keys]] adresine giderek. **New SSH key** kısmından ekle. //Title// kısmına istediğini yazabilirsin. 
- 
-===== Config Dosyası oluşturma ve hazırlama ===== 
- 
-  - Git Bash üzerinden ''touch config'' komutunu gir. 
-  - Yukarıdaki kod o klasörde **config** isminde uzantısız bir dosya oluşturacaktır. O dosyayı herhangi bir metin editörü ile aç ve içerisine aşağıdakileri yapıştır. 
- 
-<code bash> 
- #__GITUP_KULLANICI_ADI__ account 
- Host github.com-__GITUP_KULLANICI_ADI__ 
- HostName github.com 
- User git 
- IdentityFile ~/.ssh/__GITUP_KULLANICI_ADI__ 
-  
- #__GITHUP_KULLANICI_ADI_2__ account 
- Host github.com-__GITHUP_KULLANICI_ADI_2__ 
- HostName github.com 
- User git 
- IdentityFile ~/.ssh/__GITHUP_KULLANICI_ADI_2__ 
-</code> 
- 
-Kullanıcı adı kısımlarını kendine göre düzenle. Sayıyı istediğin kadar arttırabilirsin. 
- 
-===== Githup Repolarını Farklı Hesaplar Kullanarak Klonlama ===== 
- 
-Aşağıdaki komut ile klonlama yapabilirsin yada direkt HTTPS üzerindende klonlama yapabilirsin. 
- 
-<code bash> 
-git clone [email protected]{__GITHUP_KULLANICI_ADI__}:{__REPO_SAHIBININ_KULLANICI_ADI__}/{__REPO_ADI__}.git 
-</code> 
- 
-Commitlerin hangi hesapla yapılacağını belirlemek için her repo için ayrı ayrı kullanıcı ayarları yapman gerekmekte. Global ayarlar sadece tek bir hesap için kullanılabilir. Tüm var olan repolarına ve gelecekte klonlayacağın repolarında her zaman aşağıdaki işlemleri yap. 
- 
-<code bash> 
-     git config user.email "__GITHUP_MAIL_ADRESI__" 
-     git config user.name "__GITHUP_KULLANICI_ADI__" 
-      
-     git config user.email "__GITHUP_MAIL_ADRESI_2__" 
-     git config user.name "__GITHUP_KULLANICI_ADI_2__" 
-</code> 
- 
-Elbette sayıyı arttırabilirsin. 
- 
-Son olarak **pull** ve **push** kullanabilmek için remote origin eklememiz gerekmekte. Aşağıdaki komutu her repon için çalıştır. 
- 
-<code bash> 
-git remote add origin [email protected]__GITHUP_KULLANICI_ADI__:__GITHUP_KULLANICI_ADI__ 
-      
-git remote add origin [email protected]__GITHUP_KULLANICI_ADI_2__:__GITHUP_KULLANICI_ADI_2__ 
-</code> 
- 
-**Kaynak**: [[https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent]] 
- 
- 
-<wrap onlyprint>[[tr:cs:git:multiple_account|UCH Viki]]'den alınmıştır.</wrap> 
-<wrap hide> 
-===== NOTLAR ===== 
-Kaynak gösterme kısmı için düzenleme yapıldığında burası düzenlenecek. 
-</wrap> 
en/cs/git/basic/multipleaccount.1746305009.txt.gz · Last modified: 2025/05/03 20:43 by ulascemh