LoginSignup
9
9

More than 5 years have passed since last update.

Gitメモ

Posted at

Tips

git logをdiff付きで見る

$ git log -p

ゴミ掃除

$ git gc --prune=now

編集中のファイルを今のブランチじゃないところにコミットしたい

$ git stash save
$ git stash branch tmp-hoge <stash>
(これでstashに退避した修正がブランチとして作成される)

あとはmergeするなりなんなりすればいい

ブランチ操作

ブランチを作成

$ git checkout -b <branch>

ブランチをリモートに送信

$ git push origin <branch>

ブランチを master にマージ

$ git checkout master
$ git merge --squash <branch>
$ git diff master
$ git commit -m 'comment'

ブランチを削除

$ git branch -D <branch>
$ git push origin :<branch>

ブランチをリネーム

$ git branch -m '新しいブランチ名'
リモートからブランチを取得
$ git pull origin <branch>
$ git checkout <branch>

タグ

tag からブランチを作る

$ git chekout -b <branch> <tag>
$ git branch <branch> <tag>
$ git checkout <branch>

tagを新しく作る

$ git tag -a 1.0.0 -m 'v1.0.0'

タグをremoteにpushする

$ git push origin 1.0.0

タグを表示する

$ git tag

tagをremoteから取得する

$ git fetch --tags
   or
$ git pull --tags

tagを削除する

$ git tag -d 1.0.0

remoteにも反映させる。(タグ名に':'をつける)

$ git push origin :1.0.0
9
9
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
9
9