LoginSignup
0
0

More than 1 year has passed since last update.

Gitあれこれ

Last updated at Posted at 2019-08-28

Git(GitHub含む)でのあれこれのメモです。

GitHubリポジトリにtagの追加/削除を行いたい


// 追加
$ git tag {tag_name}
$ git push origin {tag_name_a} {tag_name_b}

// コミット指定
$ git tag {tag_name} {commit_hash}

// 削除
$ git tag -d {tag_name}
$ git push origin -d {tag_name_a} {tag_name_b}

// ローカルのタグリスト
$ git tag -l

// タグを打ったコミットを確認
$ git show {commit_id}

// リモートのタグリスト(commitID含む)
$ git ls-remote --tags

参考

https://git-scm.com/book/ja/v1/Git-%E3%81%AE%E5%9F%BA%E6%9C%AC-%E3%82%BF%E3%82%B0
https://stackoverflow.com/questions/25984310/how-to-see-remote-tags

マージコミットの巻き戻し

マージコミットの場合は、どのコミットに戻すのか(1つ前のマージコミットかその間にあるコミットか)を指定する。それが -m オプション

$ git log
commit <commit_id>
Merge:<1> <2>
$ git revert --no-edit -m 1 <commit_id>

参考

特定コミットにチェックアウトしたい

$ git checkout <SHA>

参考

submoduleをリモートブランチの内容に更新したい

submoduleが入っている特定のリポジトリをcloneしてきた以降の話。
git submodule addした時はコミットに表現されないので、ブランチを切って行うと履歴に残せる。


// 対象submoduleの登録
$ git submodule add git@github.com:{user_name}/{repository_name}.git {dirctory_name}
'dirctory_name' already exists in the index

// 一度ディレクトリをアンステージする必要性があるらしい
$ git rm -r {dirctory_name}

// 再度登録
$ git submodule add git@github.com:{user_name}/{repository_name}.git {dirctory_name}

masterの差分を全て取り込む。

$ git pull origin master
$ git checkout -b branch-b
$ git rebase master
$ git checkout --ours <filename>
$ git rebase --continue

変更差分でファイル一覧が欲しい

$ git log --name-only

git操作を巻き戻したい

$ git reflog
$ git reset --hard HEAD@{5}

変更されたファイル一覧を取得したい

$ git log --name-only 

$ git log --name-only --oneline
0
0
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
0
0