LoginSignup
0
0

More than 3 years have passed since last update.

gitの基本コマンド

Posted at

gitの基本

gitは、作業ディレクトリ→ステージング→ローカルリポジトリ→リモートリポジトリの4つの領域に分けることができる。
この内、作業ディレクトリ、ステージング、ローカルリポジトリの3つはローカル環境(自分のパソコンの中)で管理されている。
Untitled (Draft)-1.jpg

主なgitコマンド

git init

git init
  • リポジトリを新しく作成する。
  • ファイルの中に.gitという隠しフォルダが作られる。

git add

git add
  • 作業ディレクトリからステージングに移動させる。
  • addの後ろにファイルを指定できる。
    • git add -A (gitで管理していないファイルも含めてすべてのファイルが対象になる。)
    • git add . (今いるディレクトリのすべてのファイルが対象になる。)
    • git add 【ファイル名】 (ファイル名に指定したファイルが対象になる。)

git commit

git commit -m"【コメント】"
  • ステージングからローカルリポジトリに移動させる。
  • -mの後ろにコメントを付ける。

git remote

git remote add origin 【githubで作成したリポジトリのURL】
  • ローカルリポジトリとリモートリポジトリを紐付ける。

git push

git push origin master
  • ローカルリポジトリにあるファイルをリモートリポジトリに移動させる。
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