新石器Wiki

近年はシリコン(石)から進化した便利なもので溢れる時代。そんな気になった事や試した事など記す。

ユーザ用ツール

サイト用ツール


software:git:git-basic-commands


**文書の過去の版を表示しています。**

Gitでよく使うコマンド

よく使うGitコマンドの備忘録。

clone

リポジトリ取得については、「Gitのサブモジュールも一緒にcloneする」記事参照。

リモートブランチの取得

リモートにどんなブランチがあるか調べる

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev_yoko
  remotes/origin/develop
  remotes/origin/master

チェックアウトしたいブランチが表示されていない時は、フェッチで情報取得する。

$ git fetch

ローカルブランチ名を指定して、リモートブランチをチェックアウトする。

$ git checkout -b other_branch origin/other_branch
  • 最初の引数がローカルブランチ名
  • -bオプションを指定しておくと、自動的にそのブランチに切り替わる。
  • -bオプションを指定しないと、以下を再度する必要がある。
    git checkout -b other_branch

現在の状況確認

いまのブランチや、前回のコミットと比較してどのファイルが変更されたの状況表示。

$ git status
ブランチ master
Your branch is up to date with 'origin/master'.
 
nothing to commit, working tree clean

ブランチを切り替える

ブランチを変更

$ git checkout develop
Switched to branch 'develop'
Your branch is up to date with 'origin/develop'.

インデックス(ステージ)に追加

ファイルやディレクトリをインデックスに登録

$ git add [filename]

すべての変更がある内容をインデックスに追加

$ git add -A

参考

software/git/git-basic-commands.1571362089.txt.gz · 最終更新: 2019/10/18 10:28 by yoko