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

提供: オレッジベース
移動先: 案内検索
(ページの作成:「=== リポジトリの作成 === <syntaxhighlight lang="bash"> $ mkdir <DIR> $ cd <DIR> $ git init --bare --shared </syntaxhighlight> === clone === <syntaxhighlight lang...」)
 
97行目: 97行目:
 
$ git stash list
 
$ git stash list
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
 +
[[Category:Git]]

2017年12月14日 (木) 15:15時点における版

リポジトリの作成

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

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

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

e.g

$ git checkout -b develop origen/develop

or 以下のようなエラー出る場合

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