Sar命令是一个分析系统性能的工具,这里简单介绍以下sar命令如何使用
23时03分27秒 CPU %user %nice %system %iowait %steal %idle 23时03分28秒 all 2.76 0.00 2.01 0.00 0.00 95.23 %user 在用户模式下的百分比 %nice 如果通过renice调整了nice值,那么调整过的程序cpu占用的百分比 %system 在内核运行的百分比 %iowait 在io上阻塞时间的百分比,如果明显高,说明io压力很大 %steal 虚拟cpu等待实际cpu的时间百分比。说明虚拟机性能有问题 %idle 空闲的cpu百分比
23时15分26秒 pgpgin/s pgpgout/s fault/s majflt/s pgfree/s pgscank/s pgscand/s pgsteal/s %vmeff 23时15分27秒 0.00 0.00 77.00 0.00 1126.00 0.00 0.00 0.00 0.00 pgpgin 页面换入计数 pgpgout 页面换出到磁盘的计数 fault 页面错误计数(major + minor) majflt major fault 的计数 pgfree 空闲链表的页面数 pgscank kswapd扫描的页数 pgscand 直接扫描的页数 pgsteal 扫描的页中每秒被回收的数 vmeff pgsteal / pgscan ,也就是回收效率,一直接近0%说明系统内存压力很大
3时26分34秒 kbmemfree kbavail kbmemused %memused kbbuffers kbcached kbcommit %commit kbactive kbinact kbdirty 23时26分35秒 10114900 12329400 2527920 15.80 115168 2967592 9403528 55.63 1030508 4108996 124 kbmemfree 剩余内存,meminfo 的 MemFree kbavail 可用内存,meminfo的MemAvailable kbmemused 已用内存,free命令里面的used %memused 物理内存百分比 kbbuffers buffer使用,meminfo的Buffers kbcached cached使用,meminfo的Cached kbcommit 保证当前系统所需要的内存 %commit kbcommit/MemTotal kbactive 活跃内存数,meminfo的Active kbinact 非活跃内存数,meminfo的Inactive kbdirty 脏页数,meminfo的Dirty
平均时间: DEV tps rkB/s wkB/s dkB/s areq-sz aqu-sz await %util 平均时间: dev7-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 tps 从物理磁盘读取IO的次数 rkB/s 读扇区的次数 wkB/s 写扇区的次数 dkB/s 丢弃IO的次数 areq-sz I/O 请求的平均大小 aqu-sz I/O请求的平均队列长度 await 每次请求IO的消耗时间,平均的 %util IO请求占用的cpu百分比
17时36分27秒 tps rtps wtps dtps bread/s bwrtn/s bdscd/s 17时36分28秒 0.00 0.00 0.00 0.00 0.00 0.00 0.00 tps 从物理磁盘读取IO的总次数 rtps 读IO请求的次数 wtps 写IO请求的次数 dtps 丢弃IO请求的次数 bread/s 读取的数量 bwrtn/s 写入的数量 bdscd/s 丢弃的数量
17时39分50秒 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked 17时39分51秒 0 697 0.10 0.18 0.10 0 runq-sz 等待运行队列长度 plist-sz 任务列表的任务数 ldavg-1 最近一分钟内的平均负载 ldavg-5 最近5分钟内的平均负载 ldavg-15 最近15分钟内的平均负载 blocked 因为IO原因在等待状态的任务数
17时41分09秒 dentunusd file-nr inode-nr pty-nr 17时41分10秒 78017 10304 97509 2 dentunusd 目录缓存中的未使用的缓存数 file-nr 系统文件句柄使用数量 inode-nr 索引节点句柄的使用数量 pty-nr pty终端的使用数量
17时41分39秒 proc/s cswch/s 17时41分40秒 0.00 431.00 proc/s 每秒创建的任务总数 cswch/s 每秒上下文切换的总数
18时13分11秒 INTR intr/s 18时13分12秒 190 28.00 INTR 中断号 intr/s cpu对中断响应的时间
sar -m USB 1 总计: BUS idvendor idprod maxpower manufact product 总计: 3 24ae 4012 200 Rapoo V500RGB Gaming Keyboard BUS USB挂的总线号 idvendor USB的vendor ID idprod USB的product ID maxpower USB设置的最大电流值 manufact 制造商 product USB类型
18时26分54秒 CPU MHz 18时26分55秒 all 2223.78 CPU CPU号 MHz 频率
平均时间: TEMP degC %temp DEVICE 平均时间: 1 29.00 29.00 coretemp-isa-0000 degC 当前摄氏度 %temp 相对设备温度,最大是temp_max
18时32分28秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s %ifutil 18时32分29秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 IFACE 网卡接口 rxpck/s 接收包数量 txpck/s 发送包数量 rxkB/s 接收包数据 txkB/s 发送包数据 rxcmp/s 接收压缩包数量 txcmp/s 发送压缩包数量 rxmcst/s 接收多播包数量 %ifutil 网卡利用率
平均时间: IFACE rxerr/s txerr/s coll/s rxdrop/s txdrop/s txcarr/s rxfram/s rxfifo/s txfifo/s 平均时间: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 rxerr/s 接收到的损坏包 txerr/s 发送包的损坏数 coll/s 当发送数据包时候,每秒钟发生的冲撞(collisions)数,这个是在半双工模式下才有 rxdrop/s 因为网络缓冲区满,接收时丢弃的包数量 txdrop/s 因为网络缓冲区满,发送时丢弃的包数量 txcarr/s carrier-errors发生的次数 rxfram/s 接收包时发生帧对齐错误的次数 rxfifo/s 接收包发生缓冲区溢出的次数 txfifo/s 发送包发生缓冲区溢出的次数
18时46分51秒 imsg/s omsg/s iech/s iechr/s oech/s oechr/s itm/s itmr/s otm/s otmr/s iadrmk/s iadrmkr/s oadrmk/s oadrmkr/s 18时46分52秒 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 imsg/s 接收到的ICMP包数量 icmpInMsgs omsg/s 发送的ICMP包数量 icmpOutMsgs iech/s icmpInEchos的数量 iechr/s icmpInEchoReps的消息数 oech/s icmpOutEchos消息数 oechr/s icmpOutEchoReps消息数 itm/s icmpInTimestamps的数量 itmr/s icmpInTimestampReps的数量 otm/s icmpInTimestampReps的数量 otmr/s icmpOutTimestampReps的数量 iadrmk/s ICMP 地址掩码请求消息的数量 iadrmkr/s ICMP 地址掩码回复消息的数量 oadrmk/s ICMP 地址掩码请求消息的数量 oadrmkr/s 发送的 ICMP 地址掩码回复消息的数量
19时11分13秒 irec/s fwddgm/s idel/s orq/s asmrq/s asmok/s fragok/s fragcrt/s irec/s 接收到的报文数 fwddgm/s 转发的报文数 idel/s 成功发送的报文数 orq/s 向IP层提供的报文数 asmrq/s 接收的IP分片数 asmok/s 成功重组的IP报文数 fragok/s 成功分片的报文数 fragcrt/s 产生的分片数
19时12分15秒 totsck tcpsck udpsck rawsck ip-frag tcp-tw totsck 被使用的socket数 tcpsck TCP的socket数 udpsck UDP的socket数 rawsck RAW的socket数 if-frag IP分片的数 tcp-tw 处于TIME-WAIT状态的连接数量
19时12分38秒 CPU total/s dropd/s squeezd/s rx_rps/s flw_lim/s total/s 网络帧数 dropd/s 溢出丢弃的网络帧数 squeezd/s 软中断的次数 rx_rps/s 唤醒cpu的次数 flw_lim/s 达到流量限制的次数
19时14分45秒 active/s passive/s iseg/s oseg/s active/s:主动连接数 passive/s:被动连接数 iseg/s:每秒接收的段总数 oseg/s:每秒发送的段总数
19时20分22秒 atmptf/s estres/s retrans/s isegerr/s orsts/s atmptf/s 重试失败数 estres/s 断开连接数 retrans/s 重传数 isegerr/s 错误数 orsts/s 包含RST flag的tcp段数
19时16分14秒 idgm/s odgm/s noport/s idgmerr/s idgm/s 每次接收的 UDP 数据报总数 odgm/s 每秒发送的 UDP 数据报总数 noport/s 接收到但是却没有应用程序在指定目的端口的数据个数 idgmerr/s 本机接收到但却无法派发的数据个数
七七八八总算整理完了sar命令的这些用法,但实际上工作中用不到这么多。或者sar的一些监控命令也可以通过其他命令实现。 不过需要留一个印象的是,如果想监控内存,缓存,CPU,IO,网络,中断这些通常需要监控的信息,可以尝试一下sar命令。
git commit一直没有一个规范,但是经常翻阅大型仓库例如linux kernel的都能感觉到commit是有一定规范的。为了让自己提交代码更合规点,这里整理了规范和一些注意事项(不一定正确哦),如下分享
Module: SubModule: Brief description of the patch ################################################################################# # Reference: https://www.kernel.org/doc/html/v5.4/process/submitting-patches.html # Notice: # 1. Only one problem was solved. # 2. Full description and justification # 3. Only one problem per patch # # Example 1: # Module: SubModule: Brief description of the patch # # Example 2: # Module: SubModule: Brief description of the patch # # Detailed description (if desired) # # Example 3: # [PATCH] Foo: Fix these things # or # [PATCH v2] Foo: Fix these things better # or # [PATCH v3 0/2] comedi: Fix these things # [PATCH v3 1/2] comedi: Fix the first thing # [PATCH v3 2/2] comedi: Fix the second thing #################################################################################
上述是.gitmessage文件,这个文件需要在自己的目录~/.gitmessage
下
为了使得这个模板生效,可以git config --global commit.template ~/.gitmessage
这样,以后提交就可以按照这个模板了。
vim ~/.vimrc
filetype plugin indent on syntax on set title set tabstop=8 set softtabstop=8 set shiftwidth=8 set noexpandtab
命令如下
:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab
update-alternatives --config editor
apt install esmtp touch ~/.esmtprc chmod g-rwx ~/.esmtprc chmod o-rwx ~/.esmtprc vim ~/.esmtprc identity "tangfengweny@gmail.com" hostname smtp.gmail.com:587 username "tangfengweny@gmail.com" password "邮箱密码" starttls required set sendmail="/usr/bin/esmtp" set envelope_from=yes set from="tangfeng <tangfengweny@gmail.com>" set use_from=yes set edit_headers=yes
vim ~/.gitconfig [user] name = tangfeng email = tangfengweny@example.com
git fetch origin git rebase origin/yourbranch
apt-get install codespell python-ply python-git vim .git/hooks/post-commit #!/bin/sh exec git show --format=email HEAD | ./scripts/checkpatch.pl --strict --codespell chmod a+x .git/hooks/post-commit
这样提交时就默认检查补丁规范了./scripts/checkpatch.pl --strict --codespell
确保提交的commit信息用 git log --oneline
能够清晰了解补丁内容
了解对应提交的maintainer
git show HEAD | perl scripts/get_maintainer.pl --separator , -- nokeywords --nogit --nogit-fallback --norolestats
如果是特定文件
perl scripts/get_maintainer.pl --separator , --nokeywords --nogit -- nogit-fallback --norolestats -f drivers/staging/vt6655/baseband.c
不要直接把补丁发送到邮件列表,要先制作一封特殊的邮件。如下
git format-patch -o /tmp/ HEAD^
先发给自己
mutt -H /tmp/0001-*.patch
也可以git发送
vim .gitconfig [sendemail] smtpserver = /usr/bin/esmtp git send-email --annotate HEAD^
git format-patch --subject-prefix="PATCH v2"
如果需要对补丁额外修改,应该在补丁下添加---,然后开始解释,git工具会忽略---下面的内容
然后在补充内容后面加剪刀符>8-----8<
这样文本会更加清晰
如下:
Signed-off-by: Your Name <my.email@gmail.com> --- Changes since v2: * Made commit message more clear * Corrected grammer in code comment * Used new API instead of depreciated API >8------------------------------------------------------8< drivers/staging/csr/bh.c
这里---下面的是补充的内容
补丁集也就是对所有提交补丁的汇总,如下
git format-patch -n --subject-prefix="PATCH vY" --cover-letter
最后发送补丁集
git send-email --to <发给谁> --cc <addresses from get_maintainer.pl output> /tmp/*.patch
可以先--dry-run
在本地实验后在发送
git send-email --to <发给谁> --cc <addresses from get_maintainer.pl output> -dry-run /tmp/*.patch
https://kernelnewbies.org/FirstKernelPatch
https://kernelnewbies.org/PatchPhilosophy
nr_free_pages 2596184 # 系统可用的页数 对应MemFree nr_zone_inactive_anon 489528 # 未活跃的页数 对应Inactive(anon) nr_zone_active_anon 599 # 对应Active(anon) nr_zone_inactive_file 516396 # 对应 Inactive(file) nr_zone_active_file 235058 # Active(file) nr_zone_unevictable 71526 # Unevictable nr_zone_write_pending 149 # dirty+writeback+unstable pages nr_mlock 8 # Mlocked nr_bounce 0 # Bounce nr_zspages 0 # allocated in zsmalloc nr_free_cma 0 # cma numa_hit 4634064 # allocated in intended node numa_miss 0 # allocated in non intended node numa_foreign 0 # was intended here, hit elsewhere numa_interleave 2880 # interleaver preferred this zone numa_local 4634064 # allocation from local node numa_other 0 # allocation from other node nr_inactive_anon 489528 # nr_zone_inactive_anon nr_active_anon 599 # nr_zone_active_anon nr_inactive_file 516396 # nr_zone_inactive_file nr_active_file 235058 # nr_zone_active_file nr_unevictable 71526 # nr_zone_unevictable nr_slab_reclaimable 32813 # SReclaimable nr_slab_unreclaimable 26640 # SUnreclaim nr_isolated_anon 0 # Temporary isolated pages from anon lru nr_isolated_file 0 # Temporary isolated pages from file lru workingset_nodes 0 workingset_refault_anon 0 workingset_refault_file 0 workingset_activate_anon 0 workingset_activate_file 0 workingset_restore_anon 0 workingset_restore_file 0 workingset_nodereclaim 0 nr_anon_pages 470838 # AnonPages nr_mapped 196874 # Mapped nr_file_pages 842283 # 文件缓存页 nr_dirty 149 # 脏页数 nr_writeback 0 # 回写页数 nr_writeback_temp 0 # WritebackTmp 文件系统的临时回写 nr_shmem 92614 # Shmem nr_shmem_hugepages 0 # ShmemHugePages nr_shmem_pmdmapped 0 # ShmemPmdMapped nr_file_hugepages 0 # FileHugePages nr_file_pmdmapped 0 # FilePmdMapped nr_anon_transparent_hugepages 0 # AnonHugePages nr_vmscan_write 0 # LRU内存回收写入页数 nr_vmscan_immediate_reclaim 0 # 优先回收的页数 nr_dirtied 515721 # page dirtyings since bootup nr_written 346168 # page dirtyings since bootup nr_kernel_misc_reclaimable 0 # reclaimable non-slab kernel pages nr_foll_pin_acquired 0 # via: pin_user_page(), gup flag: FOLL_PIN nr_foll_pin_released 0 # pages returned via unpin_user_page() nr_kernel_stack 12992 # KernelStack,kb单位 nr_page_table_pages 6858 # PageTables nr_swapcached 0 # swap cached nr_dirty_threshold 660577 # 脏页触发系统回写的阈值 nr_dirty_background_threshold 329885 # 脏页触发后台回写的阈值 pgpgin 2541198 # 从启动到现在读入的内存页数 pgpgout 1421761 # 从启动到现在换出的内存页数 pswpin 0 # 从启动到现在读入的交换分区页数 pswpout 0 # 从启动到现在换出的交换分区页数 pgalloc_dma 512 # 从启动到现在DMA存储区分配的页数 pgalloc_dma32 513 # 从启动到现在DMA 32位的存储区分配的页数 pgalloc_normal 4756880 # 从启动到现在普通存储区分配的页数 pgalloc_movable 0 # 可移除内存区 allocstall_dma 0 allocstall_dma32 0 allocstall_normal 0 allocstall_movable 0 pgskip_dma 0 pgskip_dma32 0 pgskip_normal 0 pgskip_movable 0 pgfree 7356348 # 从启动到现在释放的页数 pgactivate 365485 # 从启动到现在激活的页数 pgdeactivate 0 # 从启动到现在去激活的页数 pglazyfree 2336 pgfault 2896643 # 从启动到现在二级页面错误数 pgmajfault 6079 # 从启动到现在一级页面错误数 pglazyfreed 0 pgrefill 0 pgreuse 429609 # 不太理解,这里解释https://lkml.kernel.org/lkml/CAHk-=wgchPHqevEZ1radW1vLHKGGSaq_SCVHKgxHmQt70OSSfg@mail.gmail.com/ pgsteal_kswapd 0 pgsteal_direct 0 pgscan_kswapd 0 pgscan_direct 0 pgscan_direct_throttle 0 pgscan_anon 0 pgscan_file 0 pgsteal_anon 0 pgsteal_file 0 zone_reclaim_failed 0 pginodesteal 0 slabs_scanned 0 kswapd_inodesteal 0 kswapd_low_wmark_hit_quickly 0 kswapd_high_wmark_hit_quickly 0 pageoutrun 0 pgrotated 2 # 从启动到现在轮换的页面数 drop_pagecache 0 drop_slab 0 oom_kill 0 numa_pte_updates 0 numa_huge_pte_updates 0 numa_hint_faults 0 numa_hint_faults_local 0 numa_pages_migrated 0 pgmigrate_success 0 pgmigrate_fail 0 thp_migration_success 0 thp_migration_fail 0 thp_migration_split 0 compact_migrate_scanned 0 compact_free_scanned 0 compact_isolated 0 compact_stall 0 compact_fail 0 compact_success 0 compact_daemon_wake 0 compact_daemon_migrate_scanned 0 compact_daemon_free_scanned 0 htlb_buddy_alloc_success 0 htlb_buddy_alloc_fail 0 unevictable_pgs_culled 538811 unevictable_pgs_scanned 423920 unevictable_pgs_rescued 424015 unevictable_pgs_mlocked 202 unevictable_pgs_munlocked 194 unevictable_pgs_cleared 0 unevictable_pgs_stranded 0 thp_fault_alloc 0 thp_fault_fallback 0 thp_fault_fallback_charge 0 thp_collapse_alloc 0 thp_collapse_alloc_failed 0 thp_file_alloc 0 thp_file_fallback 0 thp_file_fallback_charge 0 thp_file_mapped 0 thp_split_page 0 thp_split_page_failed 0 thp_deferred_split_page 0 thp_split_pmd 0 thp_split_pud 0 thp_zero_page_alloc 0 thp_zero_page_alloc_failed 0 thp_swpout 0 thp_swpout_fallback 0 balloon_inflate 0 balloon_deflate 0 balloon_migrate 0 swap_ra 0 swap_ra_hit 0 direct_map_level2_splits 113 direct_map_level3_splits 2 nr_unstable 0
可以发现vmstat里面包含了很多的内存名词和信息,这些都是平时完全不知道的,要把内存这款了解透,得慢慢接触这些代码,配置和慢慢实践。上面分析vmstat过程中,很多不知道的,就没有细究了。因为还没那个功底去细究
MemTotal: 16002428 kB # 内核和系统可以使用的内存大小 MemFree: 12692524 kB # 系统尚未使用的内存 MemAvailable: 14358188 kB # free+可以被回收的内存大小 Buffers: 64908 kB # 块设备的缓存页 Cached: 1990844 kB # 磁盘或文件系统的内存缓存 SwapCached: 0 kB # 交换分区的内存缓存 Active: 955104 kB # 最近比较活跃的内存,可回收的 Inactive: 1851012 kB # 不活跃的内存 Active(anon): 2160 kB # cache里面的匿名的活跃内存 Inactive(anon): 928056 kB # cache里面的匿名的不活跃内存 Active(file): 952944 kB # cache里面的活跃内存 Inactive(file): 922956 kB # cache里面的不活跃内存 Unevictable: 188200 kB # 被内核认为无法回收的内存 Mlocked: 0 kB # mlock锁住的内存 SwapTotal: 902700 kB # swap的内存 SwapFree: 902700 kB # swap的可用内存 Dirty: 0 kB # 等待回写的脏页 Dirty+NFS_Unstable+Writeback=脏页 Writeback: 0 kB # 正在回写的脏页 AnonPages: 938576 kB # 匿名页 Mapped: 434276 kB # 被映射的页,例如库,二进制,mmap过的 Shmem: 191716 kB # 共享内存或tmpfs或devtmpfs KReclaimable: 100012 kB # 内核可被回收的内存 Slab: 202148 kB # SReclaimable+SUnreclaim SReclaimable: 100012 kB # slab中可以被回收的内存 SUnreclaim: 102136 kB # slab中不可以被回收的内存 KernelStack: 9904 kB # 给用户线程分配的内核栈消耗的页 PageTables: 16356 kB # 页表占用内存,内存占用越多使用的页表就越多 NFS_Unstable: 0 kB # 给nfs 服务的缓存 Bounce: 0 kB # 给块设备的bounce buffers WritebackTmp: 0 kB # 给用户文件系统FUSE的临时回写内存 CommitLimit: 8903912 kB # 提交虚拟内存的最大大小,也就是虚拟内存的最大申请内存值 Committed_AS: 4856984 kB # 当前系统的虚拟内存分配量 VmallocTotal: 34359738367 kB # 可用于vmalloc申请的内存大小 VmallocUsed: 33552 kB # 已用的虚拟内存大小 VmallocChunk: 0 kB # 虚拟内存最大的连续块 Percpu: 8896 kB # 给percpu机制申请器使用的内存 HardwareCorrupted: 0 kB # 内核察觉出内存出错的大小计数 AnonHugePages: 2048 kB # 给用户空间的匿名大页 ShmemHugePages: 0 kB # 给shmem和tmpfs的大页 ShmemPmdMapped: 0 kB # 已映射过的shmem大页 FileHugePages: 0 kB # 映射文件的大页 FilePmdMapped: 0 kB # 已映射过的文件的大页 HugePages_Total: 0 # 总共大页内存大小 HugePages_Free: 0 # 剩余的大页大小 HugePages_Rsvd: 0 # 预申请的大页,也就是申请了没有的 HugePages_Surp: 0 # 大页池的剩余 Hugepagesize: 2048 kB # 大页大小 Hugetlb: 0 kB # Hugetlbfs 的大页使用清除 DirectMap4k: 235016 kB # 可以映射4k页面的数量 DirectMap2M: 4624384 kB # 可以映射2M页面的数量 DirectMap1G: 11534336 kB # 可以映射1G页面的数量
https://www.kernel.org/doc/Documentation/filesystems/proc.rst http://linuxperf.com/?p=142 http://www.javashuo.com/article/p-dgjqhxgd-nc.html
随着git项目越来越多,每次环境部署的时候,不可能一个一个去clone仓库,这样太费事了。为了偷懒,我借鉴了android的repo机制,这样可以自行对自己的git仓库搭建一个简单的repo,之后使用这个repo就能方便的管理多个git仓库了。
git clone https://gerrit.googlesource.com/git-repo
由于repo会把repo url默认到
这里需要本地git地址。也可修改成gitlab地址。如下
REPO_URL = 'http://ip/git-repo.git'
git init --bare manifests.git git clone /root/work2/git/manifests.git vim manifests.git <?xml version="1.0" encoding="UTF-8"?> <manifest> <remote fetch="ssh://root@172.25.130.31/root/work2/git" name="origin"/> <default remote="origin" revision="master" sync-j="4"/> <project name="test1" path="test1"/> <project name="test2" path="test2"/> <project name="test3" path="test3"/> </manifest> git add . && git commit -m "first commit" && git push
这里通过编写xml,设置远端的git仓库为root@172.25.130.31/root/work2/git, 远端的分支名字为origin,默认的remote为origin,版本分支为master,一共三个工程,分别为test1 test2 test3,并在本地创建同样的目录名字。
这样即可编写一个最简单的manifests.xml。后续可以使用这个xml来管理整个git仓库
repo init -u root@172.25.130.31:/root/work2/git/manifests.git repo sync
此时可以看到三个仓库被正常的拉取
[root@localhost 3]# ls test1 test2 test3
在repo不断更新的过程中,可以生成快照,实际上就是生成一个xml文件,它保持了当时的repo状态,可供其他人使用。
这个类似于git tag。当需要整体出一个版本的时候,可以直接生成快照。
repo manifest -r -o tag_v1.0.xml <?xml version="1.0" encoding="UTF-8"?> <manifest> <remote fetch="ssh://root@172.25.130.31/root/work2/git" name="origin"/> <default remote="origin" revision="master" sync-j="4"/> <project dest-branch="master" name="test1" revision="831a146ccf46fe060c74f15354e9d68c3e0afbcb" upstream="master"/> <project dest-branch="master" name="test2" revision="829b53cce4538d5ae5919bc42bea7254bc1dcd9b" upstream="master"/> <project dest-branch="master" name="test3" revision="750f8d272da0b85a7bb7c42427fe9f0c72d416be" upstream="master"/> </manifest>
这里就比较显而易见了,快照保持了每个分支的分支信息,commit信息和上游信息
查看分支状态
repo status
为某个分支创建新的branch
repo start bug_1.2 test1
上面这个命令等同于
git checkout -b bug_1.4
查看分支信息
repo branch
查看所有分支的diff
repo diff
默认的xml头
<?xml version="1.0" encoding="UTF-8"?>
顶层manifest元素
<manifest> </manifest>
<remote /> name 这里的name是git remote的那个远程名字,默认是origin。如果是git的remote是其他的,这里填写对应即可 fetch 这里是git的地址,如果是ssh可以是:ssh://root@172.25.130.31/root/work2/git 如果是http或者git,就是github/gitlab上的地址 pushurl 这里是push的地址,当指定该属性的时候,这个值会和<project>标签中的name属性拼成完整的push url路径,这样当我们使用git push命令的时候,就会使用该url。如果不指定该属性,则pushurl和fetch一样。 revision 这里是默认的git branch名字。可以是master或者其他
<default /> remote 这里是remote设置的名字,代表repo拉的分支默认使用哪个remote上的 revision 当一个<project>不指定revision的时候使用该值 dest-branch 默认创建的本地分支,如果不指定,就是revision默认创建的分支 sync-j repo sync的并行数目 sync-c 如果设置为true,则只同步指定的分支(revision 属性指定),而不是所有的ref内容 sync-s 如果设置为true,则会同步git的子项目 sync-tags
<project /> name: 这里是工程名也就是哪个仓库 ${remote_fetch}/${project_name}.git path: 显式声明的存放文件路径 remote: 这里指定的远程分支名字 revision: 这里指定需要获取的git提交点,可以是master, refs/heads/master, tag或者SHA-1值。如果不设置的话,默认下载当前project,当前分支上的最新代码。 upstream: 在哪个git分支可以找到一个SHA1。用于同步revision锁定的manifest(-c 模式
xml可以直接include子xml。通过如下方式 <manifest> <include name="default.xml" /> </manifest>
<project name="test1" path="test1"> <linkfile dest="Readme" src="Readme"/> <copyfile dest="Readme.md1" src="Readme.md"/> </project>
在project下面设置可以设置软连接和拷贝。实际上等效于如下
ln -s test1/Readme Readme cp test1/Readme.md Readme.md1 ``` ## 参考链接 ``` https://gerrit-googlesource.proxy.ustclug.org/git-repo https://gerrit.googlesource.com/git-repo/+/master/docs/manifest-format.md ```