「Gitでよくやること」の版間の差分

提供: オレッジベース
移動先: 案内検索
102行目: 102行目:
  
 
[[Category:Git]]
 
[[Category:Git]]
 +
[[Category:よくやること]]

2017年12月26日 (火) 08:52時点における版

リポジトリの作成

$ mkdir <DIR>
$ cd <DIR>
$ git init --bare --shared

clone

$ git clone <REPOSITORY_PATH>

pull

$ git pull

変更の確認

$ git status

add

とりあえず全部

$ git add -A

新規作成 or 変更されたもの

$ git add .

変更があったもののみ

$ git add -u

commit

$ git commit -m "<MESSAGE>"

push

$ git push <REMOTE> <BRANCH_NAME>

merge

$ git merge <BRANCH_NAME>

branch確認

$ git branch

or

$ git branch -a

checkout

切り替え

$ git checkout <BRANCH_NAME>

新しくブランチを持ってくる

$ git checkout -b <BRANCH_NAME> <REMOTE>/<BRANCH_NAME>

e.g

$ git checkout -b develop origen/develop

checkoutできないとき

エラー内容

fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'origin/remote-name' which can not be resolved as commit?

こうする

$ git remote show <REMOTE>
$ git remote update
$ git fetch
$ git checkout -b <BRANCH_NAME> <REMOTE>/<BRANCH_NAME>

stash

とりあえず面倒なとき

$ git stash

メッセージ付きでstash

$ git stash save "<MESSAGE>"

一覧

$ git stash list