Skip to content

Instantly share code, notes, and snippets.

@whatedcgveg
Forked from suziewong/git.md
Created October 21, 2017 05:31
Show Gist options
  • Select an option

  • Save whatedcgveg/c2abb2f6e4e9f24d4903dc4ffa34a90d to your computer and use it in GitHub Desktop.

Select an option

Save whatedcgveg/c2abb2f6e4e9f24d4903dc4ffa34a90d to your computer and use it in GitHub Desktop.

Revisions

  1. @suziewong suziewong revised this gist Dec 26, 2012. 1 changed file with 19 additions and 3 deletions.
    22 changes: 19 additions & 3 deletions git.md
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,8 @@

    不需要指定key的位置。因为默认读取id_rsa了

    这样子使用起来没有任何区别,remote 也想平时一样操作即可。因为邮箱是相同的。

    #### 2.同一台电脑有2个github账号?咋办
    比如我服务器上模拟的2个用户

    @@ -35,9 +37,23 @@
    User osteach
    IdentityFile /home/suzie/.ssh/id_rsa_second




    这种情况下,需要几点**注意**

    1.remote pull push的时候有问题,因为要设置邮箱问题了
    pull的时候识别的是邮箱,2个github账号,2个邮箱,我们自然不能使用global的user.email了

    1.取消global
    git config --global --unset user.name
    git config --global --unset user.email

    2.设置每个项目repo的自己的user.email
    git config user.email "xxxx@xx.com"
    git config user.name "suzie"

    之后push pull就木有问题了



    #### 备注

    生成ssh key
  2. @suziewong suziewong revised this gist Dec 26, 2012. 1 changed file with 18 additions and 20 deletions.
    38 changes: 18 additions & 20 deletions git.md
    Original file line number Diff line number Diff line change
    @@ -16,26 +16,24 @@
    #### 2.同一台电脑有2个github账号?咋办
    比如我服务器上模拟的2个用户

    #monkeysuzie@gmail.com
    host gitlab.zjut.com
    hostname gitlab.zjut.com
    Port 65095
    User suzie
    IdentityFile /home/suzie/.ssh/id_rsa
    # IdentityFile ~/.ssh/id_rsa
    host gitlab-test.zjut.com
    hostname gitlab.zjut.com
    Port 65095
    User test
    IdentityFile /home/suzie/.ssh/id_rsa_second
    # IdentityFile ~/.ssh/id_rsa

    #837368104@qq.com
    host github-osteach.com
    hostname github.com
    Port 22
    User osteach
    IdentityFile /home/suzie/.ssh/id_rsa_second
    #monkeysuzie@gmail.com 我在gitlab的第一个账号suzie
    host gitlab.zjut.com
    hostname gitlab.zjut.com
    Port 65095
    User suzie
    IdentityFile /home/suzie/.ssh/id_rsa
    # 我在gitlab的第2个账号test
    host gitlab-test.zjut.com
    hostname gitlab.zjut.com
    Port 65095
    User test
    IdentityFile /home/suzie/.ssh/id_rsa_second
    #837368104@qq.com 我在github的账号
    host github-osteach.com
    hostname github.com
    Port 22
    User osteach
    IdentityFile /home/suzie/.ssh/id_rsa_second



  3. @suziewong suziewong created this gist Dec 26, 2012.
    48 changes: 48 additions & 0 deletions git.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    #### 1.同一台电脑可以有2个git账号(不同网站的)

    首先不同网站,当然可以使用同一个邮箱,比如我的github,gitlab,bitbucket的账号都是monkeysuzie[at]gmail.com
    这时候不用担心密钥的问题,因为这些网站push pull 认证的唯一性的是邮箱
    比如我的windows 上 2个账号一个gitlab 一个github (用的都是id_rsa)

    host github
    hostname github.com
    Port 22
    host gitlab.zjut.com
    hostname gitlab.zjut.com
    Port 65095

    不需要指定key的位置。因为默认读取id_rsa了

    #### 2.同一台电脑有2个github账号?咋办
    比如我服务器上模拟的2个用户

    #monkeysuzie@gmail.com
    host gitlab.zjut.com
    hostname gitlab.zjut.com
    Port 65095
    User suzie
    IdentityFile /home/suzie/.ssh/id_rsa
    # IdentityFile ~/.ssh/id_rsa
    host gitlab-test.zjut.com
    hostname gitlab.zjut.com
    Port 65095
    User test
    IdentityFile /home/suzie/.ssh/id_rsa_second
    # IdentityFile ~/.ssh/id_rsa

    #837368104@qq.com
    host github-osteach.com
    hostname github.com
    Port 22
    User osteach
    IdentityFile /home/suzie/.ssh/id_rsa_second




    #### 备注

    生成ssh key

    ssh-keygen -m rsa -C "your mail" (当前目录)
    然后可以命名默认id_rsa 或者id_rsa_second 把对应的pub放到公共服务器上。