Hướng Dẫn Sử Dụng Git

  • View
    36

  • Download
    2

Embed Size (px)

DESCRIPTION

Hướng Dẫn Sử Dụng Git

Text of Hướng Dẫn Sử Dụng Git

s dng TortoiseGit, cn ci t msysgit trc. T trang web di y hy ti trnh ci t (installer) ri ci t. http://code.google.com/p/msysgit/downloads/listTrnh ci t l phn ghi tm tt gi l Full installer for official Git for Windows [s phin bn]. Hy chn v ti v bn mi nht.Trc tin, t trang web sau y hy ti trnh ci t v gi ngn ng ca TortoiseGit. V c th ti v bn 32 bit v 64 bit nn hy chn bn ging vi Windows m mnh ang s dng.

Trng hp khng bit Windows ang s dng l bn 32 bit hay bn 64 bit th c th tm hiu bng cch sau y.Click chut phi vo [Computer] [Start menu], ri t menu hin ra click vo [Properties].V thng tin cn bit s c hin th phn [System type] trn mn hnh tip theo.Double click vo file trnh ci t ti v ri khi ng. Mn hnh tip theo s c hin th, click vo nt "Next".

Click tip nt "Next".

Vn gi chn [TortoisePLink] ri click nt "Next".

Gi nguyn v tip tc nhn nt "Next".

Click nt "Install".

Bt u ci t. V c trng hp yu cu chng thc l ngi dng Windows nn hy chng thc ri tip tc.

Vic ci t hon tt. Hy click nt "Finish" ri kt thc.

Tip tc s thc hin Nht ng ha. Ti Japanese t Language Packs, double click ri khi ng. Click nt "Next".Bt u ci t. V c trng hp yu cu chng thc l ngi dng Windows nn hy chng thc ri tip tc.Vic ci t hon tt. Hy click nt "Finish" ri kt thc.Hy nhn chut phi bt k u trn desktop ri cho hin th menu. V chc chn mc menu ca Git c thm vo ri nn hy click [TortoiseGit] ri chn [Settings].Mn hnh thit lp c hin th. Sau khi chn ting Nht phn [Language] mn hnh [General], hy click nt "OK".Nh vy vic ci t v Nht ng ha hon tt.-----------------------------------------------------------------------------------------------------------ng vi Git ci t, hy ng k tn ngi dng v a ch email ca mnh. Vic ny th ch cn thc hin 1 ln sau khi ci t l c. Ci ny s c hin th trong lch s xem nh l thng tin ca ngi commit chng hn.WindowsT menu khi nhn chut phi hy chn [TorotiseGit] chn [Settings].

Mn hnh thit lp s c hin th. Trn mn hnh Git hy nhp [Name] v [Email] ca phn thng tin ngi dng(User info)

Nh vy vic ci t kt thc! trang tip theo chng ta hy th to repository!-------------------------------------------------------------------------------------------------------------To repository miBy gi chng ta hy to repository mi trn local. y, hy to th mc rng vi tn l "tutorial", ri t di qun l ca Git.Trong nhng hng dn t by gi tr i s s dng th mc ny ri tin hnh.WindowsTrc tin hy to th mc repository ni ty trn my. Chn th mc tutorial di s qun l ca Git, nhn chut phi ri chn [Git Create repository here].

Khi , mn hnh tip theo s c hin th. Khng nh du chn vo mc [Make it Bare(No working directories)] ri nhn nt "OK".

Nu thnh cng th mn hnh tip theo s c hin th. Nhn nt "OK" ri ng li.

Biu tng ca th mc tutorial s hin th nh di y. Trng hp biu tng khng thay i th t menu chut phi hy nhn vo [Update to the latest status].

Tip theo, s commit file vo repository ny.-------------------------------------------------------------------------------------------------------------Commit mt tp tin(file)

Hy th thm file mi trong th mc tutorial ri ng k file vo repository.Trc tin, hy to file vn bn (text file) vi tn l "sample.txt" trong th mc tutorial. Ni dung ca file th hy nhp on vn bn nh di y.n c con kh cng hiu c lnh Git

WindowsM th mc tutorial, hy nhp chut phi vo th mc ri cho hin th menu, t menu hin ra hy click vo Git commit.Mn hnh tip theo s c hin th, nh du chn "sample.txt" khung [Changes made], sau khi nhp commit message vo mc [Message] th nhn nt "OK".

Mn hnh tip theo s c hin th, nu hin th "Success" th c ngha l thnh cng. Hy nhn nt "Close" ri ng mn hnh li.

Hy nhn vo [TortoiseGit] chn [Display log] t menu chut phi. Commit va ri s c thm vo trong lch s.

Tip theo, s trnh by v cch chia s repository vi nhau.----------------------------------------------------------------------------------------------------------Push ln remote repositoryHin ti, chng ti trnh by v cch s dng c bn ca local repository. T by gi s l phn trnh by v phng php s dng remote repository, chia s lch s thay i ca local repository.Push chia s lch s thay i ca local repository m bn thn ang c bng remote repository, cn phi upload lch s thay i trong local repository.V th, s thc hin thao tc gi l Push trn Git. Khi thc hin Push, lch s thay i ca bn thn s c upload ln remote repository v lch s thay i ca remote repository s c trng thi ging vi local repository.

Clone mt remote repositoryNu c remote repository cha lch s thay i ca ai , th s c th sao chp ton b repository v bn thn c th thao tc trn phn cng vic .Clone sao chp remote repository, s thc hin thao tc gi l "clone".Khi thc hin Clone, s ti v ton b ni dung ca remote repository, v c th to thnh local repository my khc.NoteV trong local repository clone v, lch s thay i cng c sao chp nn c th tham chiu lch s hon ton ging vi repository gc v c th commit.Pull t remote repositoryKhi chia s remote repository v nhiu ngi cng thc hin cng vic, th mi ngi s push ln remote repository. Khi , cn ly ni dung thay i m ngi khc push ln em vo local repository ca bn thn. Pull cp nht local repository t remote repository th thc hin thao tc gi l Pull.Khi thc hin Pull, s ti lch s thay i mi nht t remote repository v, ri a ni dung vo local repository ca bn thn.

Tip theo l phn hng dn cch s dng remote repository ca Backlog chia s repository nh!

To remote repository trn Backlogu tin hy to remote repository trn Backlog.TipsTrn Backlog, nu khng phi ngi dng c quyn ca ngi qun l th khng th to c Git repository. Trng hp bn thn ngi dng khng c quyn ca ngi qun l th hy nh ngi c quyn ca ngi qun l to repository gip. Hoc l ly Backlog space ca gi min ph ri s dng.Ly Space bt u t yTrc ht, ng nhp vo Backlog, t menu ca d n s to repository, click vo [Git]. Trng hp cha c d n no th hy to d n.

Trng hp mc Git khng c hin th th chn d n cho kch hot chc nng Git, ri thc hin "Project Settings" > "Git Settings" kch hot n.

Khi chc nng Git c kch hot, cng t mn hnh thit lp Git s click [Add Repository].

Nhp [Repository name] v [Description], ri click vo nt "Create Repository". y nhp vo trong phn tn l "tutorial" v trong phn gii thch l "For use in the tutorial".

Ging nh hnh di y, repository mi c thm vo.

Tip theo s push ln remote repository ny.

Push ln remote repositoryHy push local repository "tutorial" to trong mc "Hng dn Git c bn".

WindowsNhn chut phi vo th mc [tutorial], ri nhn vo [push].

mn hnh k tip hin th nhn vo nt "Manage".

mn hnh k tip hin th, mc [Remote] nhp vo "origin", mc [URL] nhp vo URL ca remote repository to trang trc, nhn vo nt "Add New/Save". Trong danh sch remote th "origin" s c thm vo, nhn vo nt "OK".

TipsTrng hp console, khi thc hin push v pull nu tnh lc tn ca remote repository th s s dng tn ca remote repository l origin. Chnh v vy, trong remote repository t tn l "origin" l vic thng thng hay gp.Chn origin thm khi ny mc [Remote] ca mn hnh push, ri nhn nt "OK".S c yu cu nhp vo tn ngi dng nn hy nhp tn ngi dng ca Backlog.

Tip theo s c yu cu nhp mt khu nn hy nhp mt khu ca Backlog.

Mn hnh hin th tip theo c hin th, v n hin th "Success" ngha l vic push hon tt.

Hy m trang Git ca Backlog. Mc push c thm vo mc cp nht gn y.

File ca repository push c thm vo trong danh sch file ca repository.

Tip theo s thc hin clone remote repository ny.

Clone mt remote repositoryHy th thc hin sao chp remote repository v c th thc hin cng vic ni khc.By gi hy gi nh rng l thnh vin khc trong nhm, thc hin clone remote repository sang th mc khc c tn l "tutorial2".WindowsClick chut phi bt c u trn desktop, ri hy click vo [Git Clone] menu hin th.

Nhp URL ca remote repository s clone v th mc s lu local repository, ri click nt "OK". y s clone remote repository to trang trc vi tn th mc l "tutorial2".

Mn hnh tip theo s c hin th v vic clone s bt u. Nu "Success" c hin th ngha l vic clone thnh cng. Hy click nt "Close" v ng mn hnh li.

Th mc "tutorial2" c to.

Trong repository "tutorial2" sao chp, hy kim tra xem file sample.txt vi ni dung sau y c lu hay cha.n c con kh cng hiu c lnh Git

Push t repository cloneHy th push t local repository c to bng cch sao chp.Hy chn mi trng m my tnh s dng Windows

WindowsTrc tin, file sample.txt c trong th mc ca repository sao chp t trang trc, sau khi thm ni dung phn ch in m vo th hy thc hin commit.n c con kh cng hiu c lnh Gitadd: ng k thay i trong indexThao tc trn tutorial2Commit ca local repository tin trin n mt mc.

Thao tc trn tutorial2Tip theo, s push commit ny. Nhp chut phi vo th mc "tutorial2", hy nhn [Push].

Thao tc trn tutorial2V mn hnh tip theo s c hin th nn hy nhn nt "OK".

Thao tc trn tutorial2Mn hnh tip theo c hin th v bt u push. Nu hin th l Success th c ngha l vic push thnh cng. Nht nt "Close" ri ng mn hnh.

Thao tc trn tutorial2Hy nhn [TortoiseGit]> [Display log] trn menu hin th khi nhn chut phi. By gi th [master] v [origin/master] l cng cp . iu ny c ngha l remote repository c cp nht nhng thay i mi nht v c ng b vi local repository.

TipsHy cng tm tt v v tr ca commit mt ln. origin/masterang hin th v tr branch [master] ca remote repository [origin]. origin/HEADang hin th v tr ca commit s c ti v khi clone remote repository [origin]. Thng thng ch v tr ging vi [origin/master]. masterang hin th v tr branch [master] ca local repository.V branch th s trnh by chi tit trong phn Pht trin.Hy m trang Git ca Backlog. Commit push hin ti c thm vo cp nht mi nht.

Pull t remote repositoryHy a ni dung thay i mi nht t remote repository vo tutorial.

WindowsHy th a ni dung push remote repository t [tutorial2] trang trc vo [tutorial].Thao tc trn tutorial. thc hin pull, click chut phi th mc [tutorial], ri t menu hin ra nhn [pull].

Thao tc trn tutorial.V mn hnh tip theo s c hin th nn hay nhn nt "OK".

Thao tc trn tutorial.Mn hnh tip theo s c hin th v s bt u p

Search related