Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2722

gitの使い方

$
0
0

使用環境

Ubuntu OS
Bash

インストール

$ apt-get install git

参考-Gitのインストール

GitHubの設定

  1. account作成

    認証用情報の登録をして、Loginする。

  2. repository作成

    保管場所の指定と登録をする。

GitHub

よく使うコマンドの役割

  1. add

    情報の変更をGitに一時保存します。

  2. commit

    addした情報をGitの版管理対象に登録します。

  3. push

    commitした情報をGitHubなどのremote repositoryに登録します。

  4. clone

    remote repositoryをlocal repositoryに持ってきます。

  5. fetchとmerge

    remote repository(GitHubなど)と結びついているbranchをorigin/masterブランチといいます。
    origin/masterブランチは、localに存在します。
    手元のPCの作業フォルダと結びついているブランチをmaster といいます。
    つまり、localには、ブランチが2つ存在しています。
    fetchは、remote repositoryの情報をorigin/masterブランチに持ってきます。

    mergeは、origin/masterブランチの変更を作業フォルダであるmasterブランチに取り込みます。

実際の流れ

リモートからcloneして、変更をリモートにpushする場合

$ git init

    $ git clone https://github.com/~/~.git

何かしらの変更をする。
現在のdirectoryの変更をすべてaddするには、以下を入力する。

$ git add .

addしたfileをcommitする。"add"はコミットのコメント

$ git commit -m"add"

commitしたら、以下で、localの変更をGitHubに登録できる。

$ git push origin master

リモートからcloneして、変更をリモートにpushする場合は、以上で終わり


Viewing all articles
Browse latest Browse all 2722

Trending Articles