LoginSignup
0
0

More than 3 years have passed since last update.

git,github 初心備忘録

Last updated at Posted at 2019-10-19

[参考]
基本
https://qiita.com/mikansei-lab/items/dff17ba65b28fc82b1e1
入門
https://qiita.com/ay3/items/8d758ebde41d256a32dc

dotinstall

[環境]
mac os mojave
proxy有り
git version 2.23.0


git : バージョン管理ツール
github : gitのwebサービス版


初期設定(アカウント登録〜ssh登録)

・アカウント登録
https://github.com/

・gitインストール

$brew update
$brew install git
$git --version

・SSHkey登録

$ls -al ~/.ssh
$ssh-keygen -t rsa #enter
$ls -al ~/.ssh
$cat ~/.ssh/id_rsa.pub
→id_rsa.pubをコピー
https://github.com/settings/keys に登録

・ユーザーの追加

ユーザーの名前を指定
$ git config --global user.name [name]
ユーザーのメールアドレスを指定
$ git config --global user.mail [mail]
設定を確認
$ git config --global --list
user.name=[name]
user.mail=[mail]

・リポジトリを作成
GitHubへログイン→画面左側のRepositoriesの「New」ボタンからリポジトリを作成
Repository name:なんでも

共有リポジトリへファイルをpush

プッシュしたいソースのあるフォルダに移動
$ cd なんちゃらかんちゃら
gitの初期化
$ git init
カレントディレクトリのファイル全てをバージョン管理に追加
$ git add .
ソースのコミット
$ git commit -m "first commit"

リポジトリを追加

$ git remote add origin <URL>
*url先のリポジトリを共有リポジトリとしてoriginというあだ名をつける
リポジトリの確認
$ git remote -v
origin  https://github.com/~ (fetch)
origin  https://github.com/~ (push)

共有リポジトリ orijin=url に反映
$ git push -u origin master

*masterとは開発する際のリリース版や安定板のようなもの.個人利用ではこのままでok
master はブランチ(枝分かれ)の名前。ちなみに master は大事なブランチなので、チームでの場合はmasterには通常pushしないので注意
*「-u」オプションについて
省略の呪文。git push -u origin master とすると、次回から git push だけで引数に指定した origin master で勝手に push してくれる。

その他(originの変更,branchの確認)

originの変更

$git remote set-url origin {new url}
$git remote -v

branchの確認

$git branch
* master
  hoge

branchの切り替え
$git checkout ブランチ名

clone

$git clone {url}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0