Notes
main
main
  • Introduction
  • linuxKernel
    • tips
    • make_help
    • old linux
      • compile_linux0.11
      • TestEnvironment
      • load_setup
      • get_hard_data
    • list
    • plist
    • fifo
    • idr
    • xarray
    • rbtree
    • maple_tree
    • syscall
    • bitmap
    • page
    • page_flags
    • page_size
    • page mapcount
    • page refcount
    • folio
    • slub
      • proc_slabinfo
      • slub_theory
      • kmalloc_kfree
      • kmem_cache
      • slab_alloc
      • slab_free
      • proc_meminfo_SReclaimable_SReclaimable
    • vmalloc
    • brk
    • mmap
    • mremap
    • mprotect
    • madvise
    • read
    • write
    • shmem
    • huge_page
    • page_fault
    • rmap
    • lru
    • multi-gen-LRU
    • page_reclaim
    • page_cache
    • page_table
    • rcu
    • kvm
    • aarch64_boot
    • tracing_system
    • cache_coherence_and_memory_consistency
    • cpu_speculates
    • mmap_lock
    • per-vma_lock
    • cgroup
    • symbol
    • campact
    • page_ext
    • mempool
    • kernelstack
    • filesystem
    • io_stack
    • workingset
    • ioremap
    • sched_period
  • linuxDebug
    • openocd_openjtag
    • i2c_tools
    • objdump
    • addr2line
    • gdb_useage
    • debug_linux_kernel_via_gdb
    • debug_linux_module_via_gdb
    • early_boot
    • sequentially_execute
    • dynamic_debug
    • research_linuxKernel_by_patch
    • tracefs
    • ebpf
    • bpftrace
    • perf
    • flame_graph
    • crash
    • ASAN_HWASAN_MTE_check_mem_bug
    • page_owner
    • vmtouch
    • fio
    • benchmark
  • linuxSystem
    • common
      • system_version
      • procfs
      • proc_sys_vm
      • cmd_ps
      • makefile
      • file_descriptor
      • psi
      • ulimit
      • top
      • delay_accounting
    • ubuntu
      • custom_kernel
      • get_cmd_src
      • record_ssh_info
      • log
      • run_custom_script
      • repo
      • cockpit
      • nfs
      • tftp
      • misc
    • fedora
      • system_upgrade
      • custom_kernel
      • lvextend
      • yt-dlp
      • jellyfin
  • linuxDriver
    • i2c_peripherals_driver
    • spi_peripherals_driver
    • gpio_subsystem
    • IRQ_driver
    • blockIO_unblockIO_async
    • linux_own_driver
    • misc_device
    • input_device
    • timer
    • atomic_spinlock_semaphore_mutex
    • lcd
    • touch_screen
    • debugfs
    • v4l2
    • mmap
  • hardware
    • paging_mmu_pt
    • iommu
  • process_thread_scheduler
    • scheduler01
    • scheduler02
    • scheduler03
    • scheduler04
    • scheduler05
    • scheduler06
  • memory_management
    • mm1
    • mm2
    • mm3
    • mm4
    • mm5
  • input_output_filesystem
    • io_fs_01
    • io_fs_02
    • io_fs_03
    • io_fs_04
  • lock_and_lockup_detector
    • general_lock
    • hung_task
    • softLockup_hardLockup
    • crash_experiment
  • MIT_6.S081
    • 6.S081_Operating_System_Engineering
    • Schedule.md
    • Class
      • Overview
      • Administrivia
    • Labs
      • Tools
      • Guidance
      • startup
      • syscall
      • page_table
      • Calling_Convention
      • traps
    • xv6
      • xv6
    • References.md
  • qemu
    • qemu_buildroot
    • qemu_busybox.md
    • Serial.md
    • demo_mini2440
      • 0_compilation_error_summary
      • 1_compilation_steps
      • 2_operation_mode
      • 3_transplant_tools_libraries
      • 4_tools_use
      • reference_website
  • tools
    • getKernelSourceCodeList
    • nat
    • shell
    • translating
    • YouCompleteMe
    • cscope
    • global
    • vscode
    • vim
    • binary
    • markdown
    • draw
    • git
    • tig
    • tmux
    • mail_client
    • download_patchset_from_LKML
    • minicom
    • clash
  • other
    • interview
    • interview_c_base
    • know_dontknow
    • Stop-Ask-Questions-The-Stupid-Ways
    • How-To-Ask-Questions-The-Smart-Way
    • docker
    • buildroot
    • rv32_to_rv64
Powered by GitBook
On this page
  • DESCRIPTION
  • IMPORTING A NEW PROJECT
  • VIEWING PROJECT HISTORY
  • MANAGING BRANCHES
  • REMOTE
  • PATCH
  • SUB-MODULES
  • EMAIL
  • TIPS

Was this helpful?

  1. tools

git

DESCRIPTION

The git is source code version control software.

  1. install git, example Ubuntu/Debian.

    $ sudo apt install git
  2. Configure personal information

    $ git config --global user.name "Your Name Comes Here"
    $ git config --global user.email you@yourdomain.example.com
  3. Check personal information

    $ git config -l

IMPORTING A NEW PROJECT

init git repositories

$ git init .

add files that want to trace

$ git add <files>

commit files to git repositories for tracing

$ git commit -m '

VIEWING PROJECT HISTORY

$ git log [--reverse] [file]
$ git show <commit>

MANAGING BRANCHES

Review branch

$ git brach

Create new branch from the current tag/commit

$ git branch <new_branch> [tag_or_commint]
or
$ git checkout -b <new_branch> [tag_or_commint]

Create new branch from the previous commit of a commit

$ git branch <new_branch> <commint>~1
## such as:
$ git branch slub 81819f0fc828~1

Checkout branch

$ git checkout <branch>

Delete branch

$ git branch -d <branch>

Modify branch name

$ git branch -M <branch>

REMOTE

The remote server has github, gitlab, gitee and private git server.

Clone remote server git repositories

$ git clone <remote_url>

Push code/tags to remote server

$ git push [--tags] <remote_url> <local_branch>[:<remote_branch>]

Pull code/tags from remote server

$ git pull [--tags] <remote_url> <remote_branch>[:<local_branch>]
or
$ git fetch <remote_url> <remote_branch>:<local_branch>

PATCH

output <commit> patch only

$ git format-patch -1 <commit>

Output the patch of a certain range, such as the patch of commit1~commit3, excluding commit1 patch

$ git format-patch <commit1>..<commit3>

output all patches of a file

## such as: mm/slub.c
$ i=0; for line in `git log --reverse --pretty=format:"%h" mm/slub.c`; do i=$[$i+1]; git format-patch -1 --start-number $i $line -o patches/; done

see if the patch is applicable to the current working tree and/or the index file and detects errors. Turns off apply.

$ git apply --check <patch>

apply patch to git repositories

$ git am <patch>

SUB-MODULES

Add sub-modules into a repository

$ git submodule add <repository URL> [path]
$ git commit -m '

Cloning a repository that contains submodules

## The first method
$ git clone <repository URL>
$ git submodule update --init [--recursive]

## The second method
$ git clone --recurse-submodules <repository URL>

Update sub-modules

## The first method
$ cd <sub-modules>
$ git pull
$ cd <main-repository>
$ git add .
$ git commit -m '

## The second method
$ cd <main-repository>
$ git submodule update --remote [sub-modules]
$ git add .
$ git commit -m '

EMAIL

  1. Shell 终端能够访问 gmail 服务器

  2. 安装 git send-email 功能,执行 $ apt install git-email

  3. 配置 git send-email 功能,参考 $ git help send-email 的 EXAMPLES 小节,

完成后,就能够使用 $ git send-email 进行发送邮件

如果想要给 Linux Kernel 提交 patch,需要按照以下步骤来执行:

  1. 修改源码,编译运行,测试,确保能够正常运行 patch 对应的功能

  2. 提交源码,如下:

    $ git add xxx
    $ git commit -s -m '
    module name: fix some bugs
    
    why and how
    '
  3. 生成 patch

$ git format-patch -M origin/master -o patch/

将与 origin/master 不同的 commit 都生成 patch,存储在 patch/ 目录下

可选:

  • --cover-letter :生成以 0000- 为前缀的邮件封面,需要指定标题、简介。

  • -v <version> :指定新版本 注意:第二版本后的邮件封面,除了需要指定标题、简介外, 还需要写 版本改变日志、之前的版本在 https://lore.kernel.org 的链接

  • --base=auto :显示是基于哪一个 commit 进行修改

  • --subject-prefix="RFC PATCH": 生成 RFC PATCH 前缀,默认是 PTACH 前缀

  1. 通过 ./scripts/checkpatch.pl xxx.patch 检查 patch 格式是否符合要求

  2. 通过 ./scripts/get_maintainer.pl xxx.patch 获得 maintainer 邮箱地址

  3. 通过 git send-email --to xxx --cc xxx xxx.patch 来发送 patch 给 maintainer。 如果需要发送给多个邮箱地址,用 , 作为分隔符。如果是 patchset,发送时选择 a[ll]

TIPS

tag

## view
$ git tag
## create
$ git tag <version>

look for string

$ git grep "string"

compare differ branch

$ git diff <branch_1> <branch_2> [files_path_or_dir]

let's some commit of other branch to current branch

$ git cherry-pick <commit>

get files of some commit of other branch

$ git checkout <commit> <file name>

When you develop a feature, commit multiple changes through git commit. If you want to merge this change into a single commit, you may do so through git rebase

$ git log
commit 20b6f52f5d70a07117f6d11b2902d72f69ff1ae5 (HEAD -> test)
    add: 1

commit f845618b13247321e7b3fcd27fd94d0392dbe6f9
    3

commit 373f063d4f68a1cdec3b6b29676d4203a86b4387
    2

commit b2dba726e7606b9f5374218c236c4e2d5efb7877
    Init

# 1. Select the range that you want to merge, b2dba72~20b6f52(exception b2dba72)
$ git rebase -i b2dba72 20b6f52
or
$ git rebase -i b2dba72
or
$ git rebase -i HEAD~3
pick 373f063 2
pick f845618 3
pick 20b6f52 add: 1
## 2. Modify the above information, rearrange, and merge commit, such as rearranging 20B6f52 after 373f063 and squash to 373f063
pick 373f063 2
squash 20b6f52 add: 1
pick f845618 3
## 3. Then save and exit, change the commit information, and save the exit.
 $ git log
commit 4612f3b2bf08ef705b2b70dc8f2e1d8f14023a9b (HEAD)
    3

commit c02e774166119ff4830b5a2f4db48b97b74dd290
    2

    test: add: 1

commit b2dba726e7606b9f5374218c236c4e2d5efb7877
    Init

The remote repository has new commits, but the local repository also has new commits. How to synchronize the new commits of the remote repository to the local repository?

$ git rebase <branch>

When we need to actively merge new feature branches

$ git merge <branch>

Displays the commit of each line of a file

$ git blame <file>
or
$ tig blame <file>

当我们想要知道 commit A 是在哪一个新merge feature合入时, 如何找到对应的merge commit ?

https://blog.csdn.net/qq_39734650/article/details/116658540

## ~/.gitconfig
[alias]
	find-merge = "!sh -c 'commit=$0 && branch=${1:-HEAD} && (git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n) | sort -k2 -s | uniq -f1 -d | sort -n | tail -1 | cut -f2'"
	show-merge = "!sh -c 'merge=$(git find-merge $0 $1) && [ -n \"$merge\" ] && git show $merge'"

$ git find-merge <commit A>

当我们想要研究某一个新merge feature时,merge commit 会显示feature commit范围, 比如 (A,F],其中不包括A,包括F。如何显示此feature所有commit ?

$ git log --online --graph <merge commit>
or
$ tig <merge commit>

显示 commit A 是在哪一个版本被引入?

$ git tag --contains <commit A>

将一个已经 commit 的 patch 拆分成多个 patch,如下:

$ git rebase -i <prev_commit>
<pick to edit> <commit>
$ git reset HEAD^
$ git add --patch <file>
$ git commit -s -m '

$ git rebase --continue

查看某个版本的文件内容,如下:

$ git show <hash>:<file>

查看 [HEAD, v6.9) 范围之间的所有合并提交,如下:

$ git log --oneline --merges HEAD...v6.9

查看 [HEAD, v6.9) 范围之间的所有真正提交,如下:

$ git log --oneline --no-merges HEAD...v6.9

查看某个 commit xxx 的上一个提交,如下:

$ git show xxx^

## 查看 HEAD 的上一个提交
$ git show HEAD^

查看文件 mm/vmscan.c 第 1169 行的提交历史,如下:

$ git blame -L 1169,1169 mm/vmscan.c
2 years ago     Matthew Wilcox  d92013d1e5e47│1169│                         references = folio_check_references(folio, sc);
$ git blame -L 1674,1674 mm/vmscan.c d92013d1e5e47^
11 years ago    Minchan Kim     02c6de8d757cb│1674│                         references = page_check_references(page, sc);

查看文件 mm/vmscan.c 第 1169~1190 行,在 v6.6~v6.12 的提交历史,如下:

$ git log v6.6..v6.12 -L1169,1190:mm/vmscan.c
PreviousdrawNexttig

Last updated 28 days ago

Was this helpful?

(可选)

创建应用专用密码
通过 mutt 收发 gmail 邮件