• git常用命令


    该文档不定时更新,如有需要请收藏。

    嵌入式开发过程中,也经常使用git进行版本管理,根据项目需求对git的使用程度不一样。这里介绍一种,git的简单使用,可以满足大部分的嵌入式开发,可以说嵌入式开发使用git后,可以基本拜托掉之前的的压缩保存版本,使用比较软件进行代码比较的方式。

    这里使用git管理linux内核为例做如下说明:网上下载一个版本的linux内核,解压到本地文件夹。

    建设本地库

    首先创建.gitignore文件,这里很多教程都忽略这一步,是非常不应该的,尤其针对比较庞大的工程,编译出来很多.o等等过程文件,这些我们不需要进行版本管理,所以这里针对不需要的文件进行筛选

    查看所有文件

    ls -a

    这里已经有了.gitignore

    查看一下,文件比较长,下图没有完全罗列出来,这里的. gitignore是针对linux内核的使用的,我们实际的工程可以参考该gitignore文件修改。我们的工程很少有比linux内核更复杂的,所以参考这个gitignore文件是很有帮助的。

    cat .gitignore

    如果您的工程没有.gitignore

    则需要在当前文件夹下创建gitignore

    touch .gitignore

    编辑.gitignore

    sudo gedit .gitignore

    下面的步骤都是比较常规的,依次输入即可

    初始化本地代码仓库

    git init

    初始化完成,进去创建的文件夹,在本地创建一个文件,添加到版本控制

    git add .

    查看状态

    git status

    添加进去,再去查看状态就会看没有文件可以提交了< -m: 表示提交本版本代码的信息>

    git commit -m “v1.0”

    查看日志

    git log

    用户名: git config --global user.name "用户名"

    邮箱: git config --global user.email "邮箱"

    查看日志: git log / git log --oneline(一行显示一条日志)

    初始化git仓库,提前创建好.gitignore

    查看不同

    git diff

    查看版本信息

    git log

    这里提供一下.gitignore参考

    1. #
    2. # NOTE! Don't add files that are generated in specific
    3. # subdirectories here. Add them in the ".gitignore" file
    4. # in that subdirectory instead.
    5. #
    6. # NOTE! Please use 'git ls-files -i --exclude-standard'
    7. # command after changing this file, to see if there are
    8. # any tracked files which get ignored after the change.
    9. #
    10. # Normal rules
    11. #
    12. .*
    13. *.o
    14. *.o.*
    15. *.a
    16. *.s
    17. *.ko
    18. *.so
    19. *.so.dbg
    20. *.mod.c
    21. *.i
    22. *.lst
    23. *.symtypes
    24. *.order
    25. *.elf
    26. *.bin
    27. *.tar
    28. *.gz
    29. *.bz2
    30. *.lzma
    31. *.xz
    32. *.lz4
    33. *.lzo
    34. *.patch
    35. *.gcno
    36. *.ll
    37. modules.builtin
    38. Module.symvers
    39. *.dwo
    40. *.su
    41. *.c.[012]*.*
    42. #
    43. # Top-level generic files
    44. #
    45. /tags
    46. /TAGS
    47. /linux
    48. /vmlinux
    49. /vmlinux.32
    50. /vmlinux-gdb.py
    51. /vmlinuz
    52. /System.map
    53. /Module.markers
    54. #
    55. # Debian directory (make deb-pkg)
    56. #
    57. /debian/
    58. #
    59. # tar directory (make tar*-pkg)
    60. #
    61. /tar-install/
    62. #
    63. # git files that we don't want to ignore even if they are dot-files
    64. #
    65. !.gitignore
    66. !.mailmap
    67. !.cocciconfig
    68. #
    69. # Generated include files
    70. #
    71. include/config
    72. include/generated
    73. arch/*/include/generated
    74. # stgit generated dirs
    75. patches-*
    76. # quilt's files
    77. patches
    78. series
    79. # cscope files
    80. cscope.*
    81. ncscope.*
    82. # gnu global files
    83. GPATH
    84. GRTAGS
    85. GSYMS
    86. GTAGS
    87. # id-utils files
    88. ID
    89. *.orig
    90. *~
    91. \#*#
    92. #
    93. # Leavings from module signing
    94. #
    95. extra_certificates
    96. signing_key.pem
    97. signing_key.priv
    98. signing_key.x509
    99. x509.genkey
    100. # Kconfig presets
    101. all.config
    102. # Kdevelop4
    103. *.kdev4

  • 相关阅读:
    基于PHP+MySQL学院信息发布系统的设计与实现
    十大创新方向发布 悬镜安全强势领跑软件供应链安全与开发安全
    电脑桌面图标不见了?三招教你轻松找回
    运算方法和运算器
    【原创】浅谈指针(十二)关于static(上)
    Android学习-加载网络图片、沉浸式状态栏
    【LeetCode力扣】LCR170 使用归并排序的思想解决逆序对问题(详细图解)
    vue中动态引入图片为什么要是require, 你不知道的那些事
    鸿蒙:自定义组件、自定义函数、自定义样式
    使用js对象简单模拟虚拟dom的渲染
  • 原文地址:https://blog.csdn.net/li171049/article/details/126600961