LoginSignup
20
19

More than 5 years have passed since last update.

よく使うGitコマンド

Last updated at Posted at 2013-01-17

そこら中にありますが、まとめる機会があったので、公開します。

差異を見る

$ git diff

変更したファイルを表示

$ git status

変更したファイルを元に戻す

$ git checkout FileName

ブランチを移動する

$ git checkout BranchName

今いるブランチから新しいブランチを作り、そのブランチに移動する

$ git checkout -b BranchName

削除したファイルを戻す

$ git checkout HEAD --FileName

コミットの履歴を見る

$ git log

指定したファイルをStagingに移動させる

$ git add FileName

変更したすべてのファイルをStagingに移動させる(新規作成したファイルは移動されない)

$ git add -u FileName

StagingにあるファイルをCommitする
'-m'のオプションをつけるとコメントを追加できる

$ git commit 

Pushする

$ git push origin BranchName

ブランチ一覧を表示

$ git branch

直前にCommitしたコメントの修正

$ git commit --amend -m "コメント"

Remoteのブランチを削除する

$ git push origin :BranchName

Remoteのブランチをローカルに移動させる

$ git checkout -b BranchName origin/BranchName

ブランチを更新する

$ git fetch

変更をスタックに一時的に保存

$ git stash

スタックに保存されている変更を取り出す

$ git pop

StagingにあるファイルをStagingから下ろす

$ git reset HEAD 

一つ前のコミットに戻す

$ git reset HEAD ^

Rebaseをする

$ git rebase BranchName

Rebaseの途中でConflictが起こった時、Rebase前の状態に戻る

$ git rebase --abort

Remoteのmaster以外からPullをする

$ git pull origin BranchName

GitHubのIssueに対して、Pull Requestを送る
hubを導入する必要あり

$ hub pull-request -i ISSUE_No -h organization:BranchName

GitHubのIssueに対して、master以外にPull Requestを送る

$ hub pull-request -i ISSUE_No -b organization:BaseBranchName -h organization:HeadBranchName
20
19
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
20
19