0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Gitチートシート

Posted at

はじめに

作業しているとああしたいこうしたいとなるので、忘れずに...

削除したファイルのログを確認したい(git log)

gitLog.ps1
> git log -- [ファイルパス]

特定のコミットIDまで戻したい(git reset)

gitReset.ps1
# 特定バージョンに戻す
> git reset hard [コミットID(6 or 40 chars)]

# 手順
#  1.特定のコミットIDに戻す
#  2.リモートブランチ削除
#  3.リモートブランチにプッシュ

特定コミットを取り込みたい(git cherry-pick)

gitCherrypick.ps1
> git cherry-pick [コミットID(6 or 40 chars)]

# コミットID側を優先してマージ
> git cherry-pick -Xtheirs [コミットID(6 or 40 chars)]

# Mergeコミットを適用
> git cherry-pick -m [コミットID(6 or 40 chars)]

【参考サイト】
 ◆git cherry-pick の基本仕様と、主要なオプション
  https://www-creators.com/archives/2578

特定バージョンに戻したい(git checkout)

gitCheckout.ps1
# 特定バージョンに戻す
> git checktout [コミットid]

# 最新バージョンに戻す
> git checkout master

【参考サイト】
 ◆知らずに使ってた【git checkout HEAD -- . 】の「--」ハイフンハイフンと「.」ドットの意味
  https://qiita.com/wagase/items/5b65d0efaf3d4985256b
 ◆[git] 戻したい時よく使っているコマンドまとめ
  https://qiita.com/rch1223/items/9377446c3d010d91399b

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?