《Git基本使用.docx》由会员分享,可在线阅读,更多相关《Git基本使用.docx(5页珍藏版)》请在第壹文秘上搜索。
1、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
2、=gh-pagesgitpushorigingh-pagesgerrit如何修改一个Commit:1 .先在一个干净的repo里面把这一个commit拉取下来:gitfetchssh:/xxgxrefschanges20190826&cherry-pickFETCH_HEAD具体指令需要看gerrit冏贞右上角:PatchSets(7/7)DownloadCheckout由“G讯IchyPick,“aForEatPatCh炉tfG37PullPatch-File87e67.diff.ba6487e1167.diffpArchiveUrtbz2ItgZltXZss此时gitstatus当前是有y
3、一个commitflJ.gitlog也能看到log.2 .修改代码,然后提交到本地.gitadd#使用-amend1E跋史源这个commit信息、。gitcommit-amend3 .push到gerrit需要指定具体push到哪个idgitpushoriginHEAD:refschanges以下记录一些底层git技术.clone本地仓库$gitcloneho(egitrepositories8l038038801.git查看object文件的内容使用gitcat-file可以查看ObjeCt文件的内容,但是查看的内容是转换过的:$gitcat-file-paa548c4d7910229712
4、ba3a41e74c6db872e8ab6410644blobC30106543ed8f32af334362fa82e3a4ad71ef20fhome.md可以使用Zlib-Date命令解压看到真实内容:$zlib-flate-uncompress.*.ee0234362f82e3a4ad7Ief20f46/.:3.I02btree对象工件格式请价:tree,型.需要安装qpdf才能正常使用Zhbflate命令aptinstallqpdf一gitcat-file查看ObjeCtS文件。说明usage:gitcat-file(-t-allow-unkown-type-s-allow-unknow
5、n-typeI-eI-pI-tetconv-filters)-path=or:gitcat-file(-batch-batch-check)-follow-symlinks-textcovI-filterscanbeoneof:blob,treejcommitjtag-tshowobjecttype-sshowobjectsize-eexitwithzerowhentheresnoerror-Ppretty-printobjectscontent-tetconvforblobobjects,runtextconvonobjectscontent-filtersforblobobjects,ru
6、nfiltersonobjectscontent-pathuseaspecificpathfor-textconv/-filters-allow-uknown-typeallow-sand-ttoworkwithbrokecorruptobjects-bufferbuffer-batchoutput- -batch=showinfoandcontentofobjectsfedfromthestandardinput- -batch-check(=showinfoaboutobjectsfedfromthestandardinput- -follow-symlinksfollowin-trees
7、ymlinks(usedwith-batchor-batch-check)- -batch-all-objectsshowallobjectswith-batchor-batch-check示例# /objects七件类型$gitcat-file-t56ecla0729533fbd8d38b7964b6f8ca2cace70bacommit# objects文件K小$gitcat-file-s56ecla0729533fbd8d38b7964b6f8ca2cace7ba243# :objects文件格式化内容$gitcat-file-p56ecla0729533fbd8d38b7964b6f8
8、ca2cace7batree7f9adb36c3e987dlca9d4ba538afd8cbc74e942parentCf22ff3dl5d71863f93c36fl3d848ed84idefauthorchenan.xw1599545250+0800committerchenan.w159954525040800updateREADME.md# 世可以通过tag或branch名称6object义件$gitcat-file-tv0.1.tag$gitcat-file-pv0.1.0objectC5b97d5ae6cl9d5c5df71a34c7fbeeda2479ccbctypecommittagv.1.0taggerScottChacon1290556430-0800tagginginitialreleaseoflibgit2GiUab官方提供的gitcheatsheet.