Git基本使用.docx
git使用说明git操作笔记,初级使用教程请参考gitcheatsheet.添加文件gitadd.删除文件gitrm.提交改动到本地gitCOflroit-m.firstcommit"上传改动到服务器gitpush列出当前分支gitbranch列出所有分支,包括远程分支gitbranch-a从已有的分支创建新的分支(如从master分支),创建一个dev分支gitcheckout-bdev从服务器拉取分支到本地分支gitpullorigingh-pages:gh-pages需要才、地没有ghpages分支,否则会提示已拒绝"牌上传本地分支到远程分支gitbranch-set-upstream-to=gh-pagesgitpushorigingh-pagesgerrit如何修改一个Commit:1 .先在一个干净的repo里面把这一个commit拉取下来:gitfetchssh:/×xxg×××××x××××refschanges20190826&&cherry-pickFETCH_HEAD具体指令需要看gerrit冏贞右上角:PatchSets(7/7)DownloadCheckout由“G讯IchyPick,£“aForEatPatCh炉tfG37PullPatch-File87e67.diff.ba6487e1167.diffpArchiveUrtbz2ItgZltXZss此时gitstatus当前是有y一个commitflJ.gitlog也能看到log.2 .修改代码,然后提交到本地.gitadd#使用-amend1E跋史源这个commit信息、。gitcommit-amend3 .push到gerrit需要指定具体push到哪个idgitpushoriginHEAD:refschanges<changeid>以下记录一些底层git技术.clone本地仓库$gitcloneho(egitrepositories8l038038801.git查看object文件的内容使用gitcat-file可以查看ObjeCt文件的内容,但是查看的内容是转换过的:$gitcat-file-paa548c4d7910229712ba3a41e74c6db872e8ab6410644blobC30106543ed8f32af334362fa82e3a4ad71ef20fhome.md可以使用Zlib-Date命令解压看到真实内容:$zlib-flate-uncompress<.gitobjectsaa548c4d7910229712ba3a41e74c6db872e8ab64hexdump-C00074726565203335003130303634342068tree35.100644h0106f6d652eM64eec3l06543ed8f32af3ome.md.>.*.ee0234362f82e3a4ad7Ief20f46/.:3.I02btree对象工件格式请价:tree,型.需要安装qpdf才能正常使用Zhbflate命令aptinstallqpdf一gitcat-file查看ObjeCtS文件。说明usage:gitcat-file(-t-allow-unkown-type-s-allow-unknown-typeI-eI-pI<type>-te×tconv-filters)-path=<path><object>or:gitcat-file(-batch-batch-check)-follow-symlinks-textcovI-filters<type>canbeoneof:blob,treejcommitjtag-tshowobjecttype-sshowobjectsize-eexitwithzerowhenthere'snoerror-Ppretty-printobject'scontent-te×tconvforblobobjects,runtextconvonobject'scontent-filtersforblobobjects,runfiltersonobject'scontent-path<blob>useaspecificpathfor-textconv/-filters-allow-uknown-typeallow-sand-ttoworkwithbrokecorruptobjects-bufferbuffer-batchoutput- -batch=<format>showinfoandcontentofobjectsfedfromthestandardinput- -batch-check(=<format>showinfoaboutobjectsfedfromthestandardinput- -follow-symlinksfollowin-treesymlinks(usedwith-batchor-batch-check)- -batch-all-objectsshowallobjectswith-batchor-batch-check示例# /objects七件类型$gitcat-file-t56ecla0729533fbd8d38b7964b6f8ca2cace70bacommit# objects文件K小$gitcat-file-s56ecla0729533fbd8d38b7964b6f8ca2cace7ba243# :objects文件格式化内容$gitcat-file-p56ecla0729533fbd8d38b7964b6f8ca2cace7batree7f9adb36c3e987dlca9d4ba538afd8cbc74e942parentCf22ff3dl5d71863f93c36fl3d848ed84idefauthorchenan.×xw<chenan.xxwalibaba-inc.co>1599545250+0800committerchenan.××w<chenan.xx吨alibaba->159954525040800updateREADME.md# 世可以通过tag或branch名称"6object义件$gitcat-file-tv0.1.tag$gitcat-file-pv0.1.0objectC5b97d5ae6cl9d5c5df71a34c7fbeeda2479ccbctypecommittagv.1.0taggerScottChacon<schacon)>1290556430-0800tagginginitialreleaseoflibgit2>GiUab官方提供的gitcheatsheet.