Rebase
Rebase
shine tsarin canza tarihin sadaukarwa na reshe ta hanyar aiwatar da alkawura daga wani reshe. Maimakon amfani merge
da haɗa sauye-sauye, rebase
yana ba ku damar insert
sabbin alkawurra a cikin tarihin aikin reshe na yanzu ba tare da ƙirƙirar ayyukan haɗaka ba.
Misali, a ce kana da rassa guda biyu: feature-branch
da main
. Kuna aiki akan feature-branch
kuma kuna son aiwatar da sabbin alkawuran daga main
kan reshen ku na yanzu. Kuna iya amfani da rebase don cimma wannan:
git checkout feature-branch
git rebase main
Lokacin da kuke gudanar da wannan umarni, Git zai ɗauki ayyukan daga main
kuma amfani da su akan feature-branch
. Wannan yana nufin cewa duk abubuwan da aka aikata akan feature-branch
za su bayyana bayan aikatawa daga main
. Sakamakon shine mafi tsabta kuma mafi kyawun karantawa tarihin aikatawa akan feature-branch
.
Duk da haka, lokacin amfani da rebase, yana da mahimmanci a lura cewa canza tarihin ƙaddamarwa na iya tasiri rassan da aka raba a bainar jama'a. Don haka, idan kun riga kun tura ayyukan daga reshenku na yanzu zuwa wurin ajiya mai nisa, ana ba da shawarar kada ku yi amfani da reshe na reshe don guje wa rikice-rikice da rikice-rikicen tarihi.
Branch
Canjawa
Canza reshe a Git yana nufin tsarin motsi daga reshe zuwa wancan. Lokacin da kuka canza rassan, Git yana motsa alamar HEAD zuwa sabon reshe, yana ba ku damar yin aiki a wannan reshe kuma ku yi canje-canje ba tare da shafar sauran rassan ba.
Misali, a ce kana da rassa feature-branch
da main
. Don canzawa zuwa feature-branch
, zaku yi amfani da umarni mai zuwa:
git checkout feature-branch
Bayan canza rassan, zaku iya yin canje-canje a cikin kundin aiki. Duk commit
, add
, da checkout
umarni za su shafi reshe na yanzu.
Misali, idan ka ƙara sabon fayil kuma ka sanya shi a kan feature-branch
, reshe ne kawai zai ƙunshi ƙaddamarwa, yayin da main
bai shafe shi ba. Wannan yana ba ku damar haɓaka fasali daban, gyara kwari, ko aiki akan nau'ikan lambar daban daban. Kuna iya canzawa tsakanin rassan a duk lokacin da ake buƙata don yin aiki akan kowane reshe daban.