LoginSignup
1
2

More than 5 years have passed since last update.

Gitでよく使うコマンド一覧

Posted at

ソース管理といえばGitが主流の時代。Gitでよく使うコマンドをまとめてみました。

リポジトリを取得する

$ git clone https://xxxx.xx...git
ブランチを指定したい場合は
$ git clone -b some_branch https://xxxx.xx...git
作成されるディレクトリ名を指定したい場合は
$ git clone https://xxxx.xx...git some_directory

ブランチを作成する

まずはコピー元のブランチに切り変える
$ git checkout original_branch
ローカルにブランチを作成する
$ git checkout -b copy_branch
ブランチをリモートに登録する
$ git push -u origin copy_branch

変更内容をコミットする

すべてコミットする場合
$ git commit -a
一部のファイルをコミットする場合
$ git add コミットするファイル
$ git commit
コメントをコマンドラインで登録する
$ git commit -m 'コメント'

ブランチの切り替え

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

他のブランチをマージする

$ git merge マージするブランチ名

マージするブランチをあらかじめgit pullで最新にしておく必要があります。

履歴を確認

$ git log

特定のコミットだけマージ

$ git cherry-pick コミットID

コミットIDはgit logで確認できます。

参考:
git cherry-pickで助かりました(他ブランチのコミットを反映させる方法)
git コマンド branchの作り方

1
2
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
1
2