GitHub e bonolo ho sebelisa sesebelisoa sa mola oa taelo: "gh"!

Haeba esale u sebelisa GitHub 'me u khetha mola oa taelo joalo ka' na hore ntho e 'ngoe le e' ngoe e etsoe ntle le mathata ho GUI, mohlomong u hlokometse kamoo GitHub e qalileng ho sebelisa sesebelisoa sa bona se seng se secha se bitsoang "gh". Ke ile ka etsa qeto ea ho e thunya, hobane e ne e bonahala e tšepisa. 'Me ke ne ke e rata haholo - hoo ke neng ke batla ho etsa sehlooho ka eona!

Leha ho le joalo, pele re qala, ke hloka ho hlalosa mantsoe a 'maloa ao ke tla beng ke a sebelisa sehloohong sena.

"GH" e emetse "GitHub”. Mona ke moo lebitso la sesebelisoa le hlahang teng, kahoo le ke ke la ferekanngoa le Git ka boeona. Ho hlalosa seo e se etsang ka kakaretso, o ka theha, fereko, hlakola, sheba li-repos; theha likopo tsa ho hula; le tse ling tse ngata. Haeba u sa fumane karolo empa hape u sa batle ho tloha terminal, e boetse e fana ka sebatli se thehiloeng ho mongolo hore u shebe maqephe a GitHub.

"CLI" e emetse "Command Lke Isehokelo”. Terminal eo (kapa ho Windows, Command Prompt) ke e 'ngoe ea tsona. Haeba ho na le "CLI" e kenyellelitsoeng haufi le lebitso la sesebelisoa ("Git CLI" bakeng sa sengoloa sena), ho bolela hore sesebelisoa se sebetsa ka terminal feela. 'Me "Git CLI" moelelong ona, hantle, ke Git eo re e tsebang. Joalo ka taelo eo re e etsang e etsa boitlamo kapa re theoha ka eona.

GUI e emetse "Gsekafoto Uditshebeletso Iinterface” mme ke sebopeho seo re “tsamaisang” ho sona. Ho betere, tikoloho ea komporo ka kakaretso ke GUI.

"API key" ke mofuta o itseng oa khoele / faele ea lekunutu eo u e sebelisang ho netefatsa litšebeletso. Hlokomela hore e feta 2 factor authentication joalo-joalo ha u netefatsa ka eona. Kahoo etsa bonnete ba hore u li boloka li bolokehile le kae kapa kae moo u ke keng ua fihla teng ka mekhoa e meng.

Pele ho tsohle, sesebelisoa see ke eng? E sebetsana joang le lits'ebetso tseo re ka li etsang ka Git CLI?

"gh" e ka nkoa e le mohloli o bulehileng (mohloli o moholo Code) wrapper e sebelisang Git CLI ka boeona le GitHub APIs ho etsa lintho. Ebile, o ka fetisa liparamente ho litaelo tsa Git tseo e li sebelisang! Ke tla kena ho tsona hamorao.

Ho kenya le ho seta

Hopola hore ke tla feta ka ho instola tse sebelisa Kholo. Empa ts'ebetso e lokela ho tšoana hantle le eo u ka bang le eona ho distro e thehiloeng ho Debian - Ubuntu e na le eona libakeng tsa bona tsa semmuso ka mohlala. Bakeng sa Windows, hantle, o hloka CygWin kapa WSL ke nahana. ¯\_(ツ)_/¯

# Ha re kenye sesebelisoa pele. Hape ho kenya Git kaha ke mokokotlo # bakeng sa gh. $ pkg kenya git gh -y # Joale pele ho tsohle, re hloka ho netefatsa. Sena se tla boloka senotlolo sa # se secha sa API sebakeng sa polokelo ea lisebelisoa kahoo ha ho hlokahale hore u netefatse # hape. Haeba u se u ntse u seta GITHUB_TOKEN, sena se ke ke sa sebetsa ho se hlophisoe # pele. :) $ gh auth login

Joale, pele re tsoela pele mona, ke hloka ho supa lintho tse 'maloa.

  • pele, u se ke ua khetha "GitHub Enterprise Server" haeba ha u na mofuta o mong oa GitHub e ikemetseng.
  • Ea bobeli, sebelisa SSH sebakeng sa HTTPS haeba u na le senotlolo sa hau sa sechaba se kentsoeng akhaonteng ea hau ea GitHub. Haeba u lahleheloa ke senotlolo sa API, bonyane u ke ke ua lahleheloa ke senotlolo sa SSH kahoo e ka ba mokhoa o motle oa ho khutlela morao.
  • Taba ea boraro, khetha ho kena ka sebatli ha feela o sena senotlolo sa API letsohong! Ha e le hantle, ho ke ke ha utloahala ho ba le senotlolo se seng ha u ntse u e-na le sona.

Ha u se u qetile ho hlophisa lintho, a re bolelle Git CLI ka eona.

$ gh auth setup-git

Sena se tla etsa hore ho be le meralo e hlokahalang ea Git CLI feela haeba maikutlo a hau a kena 'me a etsa hore u sebelise Git sebakeng sa GH.

Litaelo tse ling tsa mantlha

Kaha joale u se u thehile GH, e-re ke u rute litaelo tse 'maloa tsa motheo motheong oa pale.

Pele ho tsohle, ha re re u batla ho etsa kopo ea ho hula repo ea hau ea lehae. U batla ho e fereko pele.

$ gh repo fork windowsz414/platform_manifest ! windowsz414/platform_manifest e se e le teng? O ka rata ho kopanya fereko? Ee Ho kopanya ho 'platform_manifest'... remote: Ho bala lintho: 136, ho entsoe. hole: Ho bala lintho: 100% (136/136), e entsoe. hole: Lintho tse hatellang: 100% (81/81), li entsoe. hole: Kakaretso ea 136 (delta 46), e sebelisitsoeng hape 89 (delta 12), pack-reused 0 Lintho tse amohelang: 100% (136/136), 30.70 KB | 166.00 KB/s, e entsoe. Ho rarolla li-deltas: 100% (46/46), e felile. Ho ntlafatsa ho ea holimo ho tloha ho github.com:windowz414/platform_manifest * [kala le lecha] amyrom/rosie -> holimo/amyrom/rosie * [lekala le lecha] aosp-eleven -> holimo/aosp-eleven * [kala le lecha] aosp-ten -> hodimo/aosp-ten * [lekala le lecha] motsu-11.0 -> hodimo/motsu-11.0 * [lekala le letjha] cm-14.1 -> hodimo/cm-14.1 * [lekala le letjha] dot11 -> hodimo/letheba11 * [lekala le letjha ] e/os/v1-nougat -> hodimo/e/os/v1-nougat * [lekala le letjha] mokelikeli-11 -> hodimo/mokelikeli-11 * [lekala le lecha] fox_7.1 -> hodimo/fox_7.1 * [lekala le lecha] hentai-rika -> holimo/hentai-rika * [lekala le lecha] ion-pie -> holimo/ion-pie * [lekala le lecha] leloko-15.1 -> holimo/leloko-15.1 * [lekala le lecha] leloko -17.1 -> hodimo/leloko-17.1 * [lekala le letjha] leloko-18.1 -> hodimo/leloko-18.1 * [lekala le letjha] lineage-18.1_teos -> upstream/lineage-18.1_teos * [lekala le letjha] leloko-19.0 - - > hodimo/leloko-19.0 * [lekala le letjha] le leholo -> hodimo/le leholo * [lekala le letjha] mkn-mr1 -> hodimo/mkn-mr1 * [lekala le letjha] revengeos-r11.0 -> upstream/revengeos-r11.0. 1 * [lekala le lecha] stellar-S1 -> hodimo/naleli-S11 * [lekala le lecha] teos-n -> hodimo/teos-n * [lekala le lecha] weebprojekt-11 -> hodimo/weebprojekt-XNUMX ✓ Fork e entsoeng

Joale ha re re u na le mokhatlo o ikhethileng bakeng sa liteko tsa hau tse bitsoang "wz414-labs", tseo u neng u so ka u li etsa fereko profaeleng ea hau mme u batla ho li kopanya moo ebe u bula kopo ea ho hula moo. U boetse u batla ho kopanya lekala la "cm-14.1" kahoo u ke ke ua hloka ho etsa git-checkout ho lona hape.

$ gh repo fork windowz414/platform_manifest --org="wz414-labs" -- --branch="cm-14.1" ✓ E thehile fork wz414-labs/platform_manifest ? O ka rata ho kopanya fereko? Ee Ho kopanya ho 'platform_manifest'... remote: Ho bala lintho: 136, ho entsoe. hole: Ho bala lintho: 100% (136/136), e entsoe. hole: Lintho tse hatellang: 100% (81/81), li entsoe. hole: Kakaretso ea 136 (delta 46), e sebelisitsoeng hape 89 (delta 12), pack-reused 0 Lintho tse amohelang: 100% (136/136), 30.70 KB | 120.00 KB/s, e entsoe. Ho rarolla li-deltas: 100% (46/46), e felile. Ho ntlafatsa ho ea holimo ho tloha ho github.com:windowz414/platform_manifest * [kala le lecha] amyrom/rosie -> holimo/amyrom/rosie * [lekala le lecha] aosp-eleven -> holimo/aosp-eleven * [kala le lecha] aosp-ten -> hodimo/aosp-ten * [lekala le lecha] motsu-11.0 -> hodimo/motsu-11.0 * [lekala le letjha] cm-14.1 -> hodimo/cm-14.1 * [lekala le letjha] dot11 -> hodimo/letheba11 * [lekala le letjha ] e/os/v1-nougat -> hodimo/e/os/v1-nougat * [lekala le letjha] mokelikeli-11 -> hodimo/mokelikeli-11 * [lekala le lecha] fox_7.1 -> hodimo/fox_7.1 * [lekala le lecha] hentai-rika -> holimo/hentai-rika * [lekala le lecha] ion-pie -> holimo/ion-pie * [lekala le lecha] leloko-15.1 -> holimo/leloko-15.1 * [lekala le lecha] leloko -17.1 -> hodimo/leloko-17.1 * [lekala le letjha] leloko-18.1 -> hodimo/leloko-18.1 * [lekala le letjha] lineage-18.1_teos -> upstream/lineage-18.1_teos * [lekala le letjha] leloko-19.0 - - > hodimo/leloko-19.0 * [lekala le letjha] le leholo -> hodimo/le leholo * [lekala le letjha] mkn-mr1 -> hodimo/mkn-mr1 * [lekala le letjha] revengeos-r11.0 -> upstream/revengeos-r11.0. 1 * [lekala le lecha] stellar-S1 -> hodimo/naleli-S11 * [lekala le lecha] teos-n -> hodimo/teos-n * [lekala le lecha] weebprojekt-11 -> hodimo/weebprojekt-XNUMX ✓ Fork e entsoeng

Ua bona ha kea sebelisa "-b cm-14.1" mme ke entse khang e telele. Ho tloha ka letsatsi la sengoloa sena, la 16 Pherekhong 2022, GH e na le bothata ba hore ha e fetise likhang tse khutšoane ho Git CLI ka nepo, kahoo e hloka ho etsoa joalo ka likhang tse telele ho fapana le hoo.

Ha seo se se se entsoe, o ne o kenya foldara khafetsa, o entse liphetoho, oa itlama ebe oa e sutumelletsa, 'me u se u loketse ho etsa kopo ea ho hula. Bakeng sa sena, sohle seo u se hlokang ke mokhoa o bonolo

$ gh pr create --branch="cm-14.1" Ho theha kopo ea ho hula bakeng sa wz414-labs:cm-14.1 ho cm-14.1 ho windowsz414/platform_manifest? Title teos: Fetolela ho Git-Polycule ? 'Mele ? Ho latela eng? Kenya https://github.com/windowz414/platform_manifest/pull/1

Ha o sa hlomathisetse “–branch=cm-14.1”, o tla be o theha PR ho leba “kaleng” e ka sehloohong, e leng yona e tla baka mathata ha e sa sebetswe hantle.

Mme joale, ke hloka ho kopanya PR ena, na? Kahoo ke qala ka ho kopanya repo, ke lefelle lekala le abetsoeng, ebe ke thathamisa li-PR pele.

# Ho kopanya pele. $ git clone https://github.com/windowz414/platform_manifest Cloning into 'platform_manifest'... remote: Ho bala lintho: 136, ho felile. hole: Ho bala lintho: 100% (136/136), e entsoe. hole: Lintho tse hatellang: 100% (81/81), li entsoe. hole: Kakaretso ea 136 (delta 46), e sebelisitsoeng hape 89 (delta 12), pack-reused 0 Lintho tse amohelang: 100% (136/136), 30.70 KB | 137.00 KB/s, e entsoe. Ho rarolla li-deltas: 100% (46/46), e felile. # Ebe u sheba lekaleng. $ git Checkout cm-14.1 lekala la 'cm-14.1' le hlophiselitsoe ho latela 'tšimoloho/cm-14.1'. Fetolela lekaleng le lecha 'cm-14.1' # 'Me joale ho thathamisa PRs. Lenane la $ gh pr E bonts'a kopo e le 1 ho e le 'ngoe e bulehileng ea ho hula fensetereng1/platform_manifest #414 teos: Fetolela ho Git-Polycule wz1-labs:cm-414

Kaha joale rea bona hore ho na le PR ea ho fetola sebaka se hole ho "Git-Polycule", ha re boneng hore na ho fetohile eng ka eona.

$ gh pr diff 1 diff --git a/teos.xml b/teos.xml index b145fc0..3aadeb6 100644 --- a/teos.xml +++ b/teos.xml @@ -2,7 +2,7, 414 @@ 

E bonahala e ts'episa! Nako ea ho kopana!

$ gh ho kopanya 1 ? U ka rata ho sebelisa mokhoa ofe oa ho kopanya? Khutlisetsa le ho kopanya? Ho latela eng? Kenya ✓ Kopo ea ho hula e thehiloeng hape le e kopantsoeng #1 (teos: Fetolela ho Git-Polycule)

Kaha joale ke e kopantse, u ka hlakola fereko ea hau.

$ gh repo delete --confirm wz414-labs/platform_manifest ✓ Ho hlakotsoe polokelo ea wz414-labs/platform_manifest

Ua bona hore ka kotloloho e hlakotse repo ntle le kopo ea netefatso hobane ke fetisitse "-confirm" parameter moo. Haeba u sa e fetise, u tla fumana sena:

$ gh repo hlakola windowsz414/systemd ? Tlanya windowsz414/systemd ho netefatsa ho hlakoloa:

'Me u tla hloka ho thaepa lebitso lohle la repo. Ho senya nako...

Summary

Ka mantsoe a bonolo, `gh` ke sephutheloana se bonolo sa Git CLI / Curl se kopanyang ts'ebetso e bonolo ea Git le lintho tsa GitHub API tlasa marulelo a tšoanang. U e sebelisa joang? Na e shebahala e ts'episa ho uena joalo ka ha e etsa ho nna? Re labalabela ho utloa ho tsoa ho uena!

Related Articles