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?

【Git】コマンド(随時更新)

0
Last updated at Posted at 2025-08-04

導入

また使いそうだな。でも忘れてるだろうな
て感じのコマンドをまとめています。

随時更新です。

コマンド

フォーク元の最新を取得~自分のリモートリポジトリにpush

# mainに移動して最新化
git checkout main
git fetch upstream main
git pull upstream main

# 新しい作業ブランチ作成(part3)
git checkout -b fix/issue-XXX-YYYYY

git add .
git commit -m "fix/issue-XXX-YYYYY"

# 自分のリモートにプッシュ
git push origin fix/issue-XXX-YYYYY

commitしていない変更をもとに戻す系

# 更新されているファイルをもとに戻す
git restore .
## untracked file(新規追加)ファイルを消す
# 削除対象ファイルを確認
git clean -n
# ファイルを削除
git clean -f
# フォルダごと削除
git clean -fd
# 直前のコミットのメッセージを編集
git commit --amend
# 指定したコミットのメッセージを編集
git rebase -i <修正したいコミットのひとつ前のハッシュ>
> エディタが開くので、pickをrewordに変更し、保存 > メッセージ編集画面
> 編集後はgit push(必要なら--force)で反映

追跡しないようにする

# .env.exampleを追跡対象外に
git update-index --assume-unchanged .env.example
# .env.exampleを再度追跡対象に
git update-index --no-assume-unchanged .env.example

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?