未経験エンジニアの道しるべ

新聞配達アルバイトの借金生活から2ヶ月で上場企業へエンジニア転職した元営業マン

会社PCから私用・個人のGithubにpushしたい場合の設定

subのssh鍵作成

$ cd ~/.ssh
ssh $ ssh-keygen -t rsa -C tomohiro@gmail.com -f id_rsa_sub
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa_sub.
Your public key has been saved in id_rsa_sub.pub.
The key fingerprint is:
GX1924:.ssh tomohiro.meo$ ls
config                id_rsa                id_rsa.pub        id_rsa_sub        id_rsa_sub.pub        known_hosts

ローカルブランチでgit commit まで

:rails_project tomohiro $ git init
Reinitialized existing Git repository in /Users/tomohiro/rails_project/.git/
GX1924:rails_project tomohiro $ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    .env.dev
    .gitignore
    .ruby-version
    Dockerfile
    Gemfile
    Gemfile.lock
    README.md
    Rakefile
    app/
    bin/
    config.ru
    config/
    db/
    docker-compose.yml
    lib/
    log/
    package.json
    public/
    storage/
    test/
    tmp/
    vendor/

nothing added to commit but untracked files present (use "git add" to track)
:rails_project tomohiro $ git add .
:rails_project tomohiro $ git commit -m "First commit"

Githubにpush

:rails_project tomohiro $ git remote add origin https://github.com/h2tomohiro/test.git
:rails_project tomohiro $ git push -u origin master
Counting objects: 6831, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6370/6370), done.
Writing objects: 100% (6831/6831), 25.58 MiB | 569.00 KiB/s, done.
Total 6831 (delta 834), reused 0 (delta 0)
remote: Resolving deltas: 100% (834/834), done.
remote:
remote: Create a pull request for 'master' on GitHub by visiting:
remote:      https://github.com/h2tomohiro/test/pull/new/master
remote:
To https://github.com/h2tomohiro/test.git
 * [new branch]      master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

参考にしたサイト

GitHubに登録して複数のPCからpushできるように設定する方法まとめ

http://soramugi.hateblo.jp/entry/2012/02/12/234946

1台のPCで複数のGitHubアカウントを使う(SSHとhttps)

https://dackdive.hateblo.jp/entry/2015/10/12/210547

GitHubで仕事用とプライベート用のアカウントを切り替えて使う

https://kuroeveryday.blogspot.com/2016/04/github-private-account.html