ページの作成
親となるページを選択してください。
親ページに紐づくページを子ページといいます。
例: 親=スポーツ, 子1=サッカー, 子2=野球
子ページを親ページとして更に子ページを作成することも可能です。
例: 親=サッカー, 子=サッカーのルール
親ページはいつでも変更することが可能なのでとりあえず作ってみましょう!
| この記事の要点 |
|---|
|
エラーの状況
git rebase を実行したときに、以下のメッセージが出ます:
$ git rebase main
Cannot rebase: You have unstaged changes.
Please commit or stash them.
これは「ワーキングディレクトリに未コミットの変更がある状態で rebase はできない」という意味です。rebase はコミット履歴を書き換える操作なので、未保存の変更があると消える危険があるため、git が保護のために止めています。
状況確認
まず、何が変更されているかを確認:
$ git status
On branch feature/foo
Your branch is up to date with 'origin/feature/foo'.
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git restore ..." to discard changes in working directory)
modified: src/main.py
no changes added to commit
対処方法
方法 1: stash で一時退避(推奨・もっとも安全)
# 変更を退避
$ git stash
Saved working directory and index state WIP on feature/foo: abc1234 ...
# rebase 実行
$ git rebase main
Successfully rebased and updated refs/heads/feature/foo.
# 退避した変更を復元
$ git stash pop
On branch feature/foo
Changes not staged for commit:
modified: src/main.py
注意: stash pop で競合(conflict)が起きる場合があります。その場合は手動で解決:
# 競合発生
$ git stash pop
Auto-merging src/main.py
CONFLICT (content): Merge conflict in src/main.py
# 競合を編集して解決後
$ git add src/main.py
$ git stash drop # 退避を削除(pop は自動削除されないので明示)
方法 2: 変更をコミットしてから rebase
# WIP コミットを作っておく
$ git add .
$ git commit -m "WIP: 作業中"
$ git rebase main
# ... rebase 完了 ...
# 後で WIP コミットを修正したい場合
$ git commit --amend # メッセージ修正
# または
$ git reset --soft HEAD~ # コミットを取り消してステージング状態に
方法 3: 変更を破棄して rebase
注意: 変更は完全に失われます。本当に不要な場合のみ。
# 変更を完全に破棄
$ git checkout . # トラッキング済みファイルの変更を破棄
$ git clean -fd # 未追跡ファイルを削除
# または
$ git reset --hard HEAD # 全変更を破棄してコミット状態に戻す
$ git rebase main
rebase 中に競合が発生したら
rebase 実行中に競合が起きると以下のメッセージ:
CONFLICT (content): Merge conflict in src/main.py
error: could not apply abc1234... commit message
Resolve all conflicts manually, mark them as resolved with
"git add/rm ", then run "git rebase --continue".
競合の解決手順
- 競合ファイルを編集:
<<<<<<</=======/>>>>>>>マーカーで挟まれた部分を修正 - 解決済みをマーク:
git add 解決したファイル - rebase 継続:
git rebase --continue - すべてのコミットを処理し終わるまで 1-3 を繰り返す
rebase を中断したい
$ git rebase --abort
# rebase 前の状態に戻る
関連エラー
Cannot pull with rebase: You have unstaged changes—git pull --rebaseで同じエラー、同じ対処Your local changes to the following files would be overwritten by merge— checkout / merge / pull 時の同種エラーCannot checkout: You have unstaged changes— ブランチ切替時の同種
予防策
- こまめにコミット: WIP コミットでもよいので作業中の変更を残す
- 作業前に状態確認:
git statusを習慣化 - pull の前に commit / stash: 作業中に他の人の変更を取り込む前に整理
- git config で自動 stash:
git config --global rebase.autoStash trueで rebase 時に自動 stash / 復元
関連記事
ページの作成
親となるページを選択してください。
親ページに紐づくページを子ページといいます。
例: 親=スポーツ, 子1=サッカー, 子2=野球
子ページを親ページとして更に子ページを作成することも可能です。
例: 親=サッカー, 子=サッカーのルール
親ページはいつでも変更することが可能なのでとりあえず作ってみましょう!
子ページ
子ページはありません
同階層のページ
- fatal: remote origin already exists.
- fatal: '~' does not appear to be a git repository
- Cannot rebase: You have unstaged changes. Please commit or stash them.
- remote: error: denying non-fast-forward refs/heads/master (you should pull first)
- error: pathspec ... did not match any file(s) known to git.
- The following untracked working tree files would be overwritten by checkout
- fatal: Not a valid object name: 'master'.
- Unlink of file 'ファイル名' failed. Should I try again? (y/n)
- Another git process seems to be running in this repository
- error: Your local changes to the following files would be overwritten by checkout:
人気ページ
- 1 Eclipseで「サーバーに追加または除去できるリソースがありません。」の原因と対処法
- 2 tomcat の起動 / 停止ログと catalina.log・catalina.out の違い
- 3 JavaScript base URL 取得方法|window.location.origin と SSR/Node.js 対応
- 4 YouTube Data API v3 エラー一覧|403/400/404 の主要原因と切り分け
- 5 Spring Frameworkのアノテーション一覧
- 6 Laravel エラー一覧|500/Blade/DB 接続/ルーティングの代表エラー
- 7 3Dグラフィックスとは|モデリング/レンダリング/主要ソフトウェア (Blender / Maya)
- 8 【Spring】@Valueアノテーションとは
- 9 CATALINA_HOME の確認方法 (Linux / Mac)
- 10 【Spring】@Autowiredアノテーションとは
最近更新/作成されたページ
- IPv6とは|128bitアドレス・コロン16進表記/::省略・リンクローカル・SLAAC・デュアルスタック NEW 2026-06-22 12:34:44
- VPNとは|暗号トンネル・サイト間/リモートアクセス・IPsec/SSL-VPN/WireGuardを解説 NEW 2026-06-22 12:19:10
- MAC アドレスフィルタリングの仕組みと限界 | ネットワーク入門 NEW 2026-06-22 12:19:10
- WebSocket とは 全二重リアルタイム通信 ws/wss | ネットワーク入門 NEW 2026-06-22 12:17:25
- Web通信プロトコル入門 HTTP/2・HTTP/3・WebSocket・gRPC・WebRTC | ネットワーク入門 NEW 2026-06-22 12:17:25
- HTTP/2 とは 多重化・HPACK・バイナリフレーム | ネットワーク入門 NEW 2026-06-22 12:17:25
- WebRTC とは ブラウザ間 P2P の音声・映像・データ通信 | ネットワーク入門 NEW 2026-06-22 12:17:25
- gRPC とは HTTP/2 + Protocol Buffers の高速 RPC | ネットワーク入門 NEW 2026-06-22 12:17:25
- HTTP/3 (QUIC) とは UDP ベースの低遅延 Web 通信 | ネットワーク入門 NEW 2026-06-22 12:17:25
- CDN とは エッジキャッシュ・TTL・Cloudflare/CloudFront | ネットワーク入門 NEW 2026-06-22 12:17:24
- HAProxy とは frontend/backend と設定例 | ネットワーク入門 NEW 2026-06-22 12:17:24
- ファイアウォールとは|パケットフィルタ・ステートフル・DMZ・次世代FW(L4/L7)を解説 NEW 2026-06-22 12:17:24
- TLS/SSLの仕組み|ハンドシェイク・暗号スイート・前方秘匿性・証明書検証をわかりやすく解説 NEW 2026-06-22 12:17:24
- 証明書と認証局(CA)とは|X.509・信頼チェーン・DV/OV/EV・失効(CRL/OCSP)を解説 NEW 2026-06-22 12:17:24
- iptables/nftablesとは|テーブル・チェーン・ルール例・永続化をLinux視点で解説 NEW 2026-06-22 12:17:24
コメントを削除してもよろしいでしょうか?