LoginSignup
1
1

More than 5 years have passed since last update.

gitmemo

Last updated at Posted at 2015-07-29

gitmemo

最近、仕事でもgitを使うことが増えました。
さよならsvn・・でも容量が大きなファイルはgit苦手なのでドキュメントはsvnのほうがいいですかね。

gitコマンドもろもろ

状態確認

git status
カレントディレクトリの状態をみます。
ファイルの追加、更新、削除など。

git log
コミットログが見れます。

git remote -v
リモートリポジトリの登録情報が見れます。
普通ならoriginが登録されているはず。

ブランチ関連

git branch
ローカルのブランチ一覧を表示

git branch -a
リモート含めてブランチ一覧を表示

git checkout [branch_name]
ブランチの切り替え

git checkout -b [branch name]
現在のブランチを元に新しいブランチを作成

git checkout -b [remote_repository]/[branch_name]
ex. $git checkout -b origin/develop
リモートのブランチを元に新しいブランチをローカルに作成

ステージング、コミット、プッシュ、プル

git add -n [file]
ex. $git add -n aaa.txt
いわゆるdry-run。実際には実行されません。
どのファイルが追加されるのか試せます。
後述の-uつけるときに使うと便利。

git add -u
更新のあったファイルだけaddします。
untracked filesよろしく新規追加ファイルは追加されません。
-nつけて確認がおすすめ。

git add -A
すべてのファイルをaddします。
新規ファイルも追加されます。
おなじく-nつけて確認がおすすめ。

git commit -m 'commit message'
コミットメッセージ付でコミットできます。
mオプションなしだと、viでの編集画面が開いてメッセージを入力できます。

git push origin master
リモートリポジトリoriginのmasterブランチに内容をプッシュします。

git pull origin master
リモートリポジトリoriginのmasterブランチの情報を取得して、マージします。
pull = fetch + merge

追記中...

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