Git --- Remaind and Tips memorandam for Git on Python and Google Colab ---Git活用のヒントand備忘メモ
URL of the last BLOG
https://shikuuk.blogspot.com/2025/12/google-colab-is-coming-to-vs-code.html
Previously I made the Virtual Dam Creat Code on my BLOG above. But I have had a part of improvement point in that code.
In advance, I commited the latest version code, that has finished as calculate the vertiaul dam, for Git below. Then I try to change a part of code, which selects a upper side among the either side of vurtual dam wall.
I created new branch, 'fuature/20251214_VirtualDam' by below code.
After that, I confirm the current branch below, so the current branch is shown 'fuature/20251214_VirtualDam', like below.
I reviced a part of the virtual dam create codes, show below surrounded by red frame line.
I think that this revicing is acting on the Feature branch, so I close this revicing code once. Then I move to Master brach, I make sure that the same code on the Master branch is not change this part.
I run below Git's code.
After running, I open the Virtual Dam Creat code.
Above code is saved on the master branch. Oh! A part of red line frame is shown past content. Amazing!!!
So after I close the Vurtual Dam Create Code, I try to merge the feature branch content to master branch.
whin I open that code,
Oh, my God, the code in master branch is relocated by the latest code.
I asked Gemini what the featureBranch will look like after this operation. Master Gemini
answered like below in Japanese(Sorry, my native laungage is Japanese.)
マージした後の feature ブランチがどうなるか、結論から言うと 「そのまま残り続けます」。
マージによって feature ブランチの中身が消えたり、自動的に削除されたりすることはありません。具体的には以下のような状態になります。
1. 状態:中身は master と同じ(または含まれた)状態
マージが成功した時点で、master ブランチは feature ブランチで行ったすべての変更を取り込んだ状態になります。
このとき、feature ブランチ自体も、最後にコミットしたときの状態のままそこに存在しています。
2. その後の扱いは「自由」
マージ後の feature ブランチをどうするかは、その後の作業予定によります。
パターンA:削除する(一般的)
その機能の開発が完全に終わり、もうそのブランチで作業することがないのであれば、削除するのが一般的です。ブランチが増えすぎると管理が大変になるため、「使い終わった付箋を捨てる」ような感覚で消してしまいます。
削除コマンド:
Bash!git branch -d feature※
masterにマージ済みであれば、このコマンドで安全に消せます。
パターンB:そのまま作業を続ける
もし、その feature ブランチを使ってさらに追加で開発したい場合は、そのまま使い続けても構いません。
新しくコミットを重ねて、区切りがついたところでまた master へマージする、という流れを繰り返すことができます。
💡 よくある疑問
「削除したら master に取り込んだ分も消えちゃう?」
いいえ、消えません。 マージされた内容はすでに
masterの履歴の一部になっているので、元のfeatureブランチを削除しても、master側のコードや履歴に影響はありません。
「削除し忘れたらどうなる?」
特に実害はありません。ただ、数ヶ月後に「このブランチってまだ使ってるんだっけ?」と混乱する原因になるので、マージして不要になったらその場で消す習慣をつけるのがおすすめです。
まとめ:
マージしても自動では消えないので、「仕事が終わったら自分で片付ける(削除する)」 というのが Git の標準的な運用ルールです。
If you leave FeatureBranch as it is, it will become difficult to organize, so it is common to delete it once you are done with it. So I run below code for deleting the fearture branch.
This thema has been completed.
コメント
コメントを投稿