Git 提交指定文件的部分修改

2023-12-15 04:51:09

1、问题:

被分配了两个Bug,已经改好了A, 正在处理B, 但被要求先提交A, AB有修改在同一文件里,那么问题来了:Git 如何提交文件的部分修改?

2、命令:

git add --patch | -p <filename>
lee@leedeMacBook-Pro git_learn % git add -p --help
usage: git add [<options>] [--] <pathspec>...

    -n, --dry-run         dry run
    -v, --verbose         be verbose

    -i, --interactive     interactive picking
    -p, --patch           select hunks interactively
    -e, --edit            edit current diff and apply
    -f, --force           allow adding otherwise ignored files
    -u, --update          update tracked files
    --renormalize         renormalize EOL of tracked files (implies -u)
    -N, --intent-to-add   record only the fact that the path will be added later
    -A, --all             add changes from all tracked and untracked files
    --ignore-removal      ignore paths removed in the working tree (same as --no-all)
    --refresh             don't add, only refresh the index
    --ignore-errors       just skip files which cannot be added because of errors
    --ignore-missing      check if - even missing - files are ignored in dry run
    --chmod (+|-)x        override the executable bit of the listed files

文章来源:https://blog.csdn.net/qq_39852676/article/details/135007280
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。