是否存在类似于汞的情况git add -p?
从man引用,使用选项-p(或--patch)进行git-add执行以下操作:
在索引和工作树之间以交互方式选择补丁,并将它们添加到索引中.这使用户有机会在将修改后的内容添加到索引之前查看差异.
我正在使用git跟踪一些配置文件.我通常做一个交互式,git add -p但我正在寻找一种方法来自动添加与模式匹配的所有新/修改/删除的行.否则,我需要花费很多时间来完成所有交互式拆分并添加.git add有一个模式匹配的文件名,但我找不到有关内容的任何内容.
说我在尝试合并后进入时有这个git status:
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# added by them: myfile1.xhtml
# added by them: myfile2.xhtml
# added by them: myfile3.xhtml
Run Code Online (Sandbox Code Playgroud)
...而且我知道我想为每个文件执行此操作:
git checkout --theirs myfile1.xhtml
git add myfile1.xhtml
Run Code Online (Sandbox Code Playgroud)
......但其中有很多.我怎么能批量做?
我有一个源文件,其中添加了2个功能.为了允许采摘樱桃,我想分两个阶段:每个功能一个.到目前为止,在类似的情况下,使用git add -p我很好,提交一个功能,同时将本地文件留在最后阶段.
但是,我现在git add -p遇到了一个问题,即想要包含两个功能的编辑.即使编辑是在单独的行上,s(对于"拆分")不再想要将大块分成更小的部分......
简而言之:我无法通过这种方式分离2个功能的更改.有没有办法手动编辑补丁,例如使用vi,而不实际更改原始文件?
之间有什么区别:
git add .
Run Code Online (Sandbox Code Playgroud)
和
git add --all
Run Code Online (Sandbox Code Playgroud)
?
试图通过git add -p和split选项将一个大块分成较小的一个,但是整个文件看起来像一个大块而且我不能拆分它.
git help add 说我应该拆分,我记得使用它,但在我当前的例子中,该选项没有出现在提示中.Git版本:1.9.1.Xubuntu 14,哦-my-zsh.大块头不是一行,而是多行.任何想法为什么会这样?
编辑了更多数据,这里是控制台日志:
+last line of long text
Stage this hunk [y,n,q,a,d,/,e,?]? s
y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk nor any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk nor any of the later hunks in …Run Code Online (Sandbox Code Playgroud) 我有一个包含以下更改的文件:
# Manual hunk edit mode -- see bottom for a quick guide
@@ -280,6 +281,7 @@
if( foo )
{
bla();
- test( true );
+ removeThis();
+ test( false );
}
else
Run Code Online (Sandbox Code Playgroud)
我怎样才能提交更改test(),并避免提交removeThis()?每次我尝试手动编辑大块时git告诉我它不适合干净利落.
我最近更新了Git版本2.7.2.windows.1(我正在运行Windows 7 64位).自更新以来,我无法git add使用-p名称为_(下划线)的特定目录(或其子目录)中的文件选项运行.
git status 正确报告我的文件有变化:
PS C:\Users\Carl\www\dl> git status
On branch develop
Your branch is up-to-date with 'origin/develop'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: _/php/class.Menu.php
Run Code Online (Sandbox Code Playgroud)
我可以用简单的方法添加整个文件git add,或者通过名称指定文件.但是,如果我尝试包含-p或--patch选项(两个变体产生相同的结果),Git报告没有变化:
PS C:\Users\Carl\www\dl> git add -p .\_\php\class.Menu.php
No changes.
Run Code Online (Sandbox Code Playgroud)
这只发生在_目录中的文件中,但无论我是否cd进入该目录运行git add命令而不必明确指定其中带有下划线的路径都无关紧要; …