へんてこのブログ

日々気づいたことや、最近やっていることを書いています

学内LANでのgithub利用まとめ(CUI版)

学内LANでのgithub利用まとめ(CUI版)

リポジトリを最初から作る場合

githubにてリポジトリを作成しておく

//proxy設定
$ git config --global http.proxy {proxy url}:{port}
//普通のgit
$ mkdir {リポジトリ}
$ cd {リポジトリ}
$ git init

ファイル編集

$ git add .
$ git commit -m 'first commit'
$ git remote add uec https://github.com/{githubのアカウント名}/{リポジトリ}.git
$ git push uec master
//pull
$ git pull uec master

リポジトリをcloneしてくる場合

//proxy設定
$ git config --global http.proxy {proxy url}:{port}
//clone
$ git clone https://github.com/{githubのアカウント名}/{リポジトリ}.git
//push
$ git push origin master
//pull
$ git pull origin master
//上のは紛らわしいので、originは削除しましょう(uecをproxy環境専用とした方が一貫性ある)
$ git remote rm origin
$ git remote add uec https://github.com/{githubのアカウント名}/{リポジトリ}.git
//push & pull
$ git push uec master
$ git pull uec master

proxy環境外

//configの設定を初期に戻す
$ git config --global http.proxy ""
//あとは普通のgitの設定
$ git remote add origin git@github.com:{githubのアカウント名}/{リポジトリ}.git
$ git push origin master
$ git pull origin master