相关疑难解决方法(0)

在Vim中上下移动整条线

在Notepad ++中,我可以使用Ctrl+ Shift+ Up/ Down来上下移动当前行.在Vim中有类似的命令吗?我看过无尽的向导,却一无所获.

如果没有,我怎么能将动作绑定到该组合键?

编辑:Mykola的答案适用于所有行,除了缓冲区的开头和结尾处.向上移动第一行或向下移动底线会删除该行,当向下移动底线时,它最初会跳转两个空格,就像一个棋子!任何人都可以提供任何改进吗?

vi vim

301
推荐指数
13
解决办法
13万
查看次数

如何从git diff读取输出?

手册页git-diff很长,并解释了许多初学者似乎不需要的案例.例如:

git diff origin/master
Run Code Online (Sandbox Code Playgroud)

git diff git-diff

254
推荐指数
5
解决办法
9万
查看次数

为什么`git stash -p`有时会失败?

我♥ git stash -p.但有时,一个令人满意的会议结束后y,ns,我得到这个:

Saved working directory and index state WIP on foo: 9794c1a lorum ipsum
error: patch failed: spec/models/thing_spec.rb:65
error: spec/models/thing_spec.rb: patch does not apply
Cannot remove worktree changes
Run Code Online (Sandbox Code Playgroud)

为什么?

git git-stash

73
推荐指数
4
解决办法
5710
查看次数

编辑git patch给出"你编辑的hunk不适用"

我正在以交互方式添加文件:

git add ../../template/panels/panel-reports.php -p
diff --git a/template/panels/panel-reports.php b/template/panels/panel-reports.php
index 5482228..48d2901 100644
--- a/template/panels/panel-reports.php
+++ b/template/panels/panel-reports.php
@@ -214,6 +214,8 @@

                        <a class="addCategory"></a>
                        <a class="removeCategory"></a>
+                       <a class="addDocument"></a>
+                       <a class="checkTool"></a>

                        <div class="categoriesList"></div>
                        <div class="documentsList"></div>
Stage this hunk [y,n,q,a,d,/,e,?]? e
Run Code Online (Sandbox Code Playgroud)

ps:这些是这里唯一的修改过的行

我想删除

+                       <a class="checkTool"></a>
Run Code Online (Sandbox Code Playgroud)

所以我这样编辑:

# Manual hunk edit mode -- see bottom for a quick guide
@@ -214,6 +214,7 @@

                                                <a class="addCategory"></a>
                                                <a class="removeCategory"></a>
+                                               <a class="addDocument"></a>

                                                <div class="categoriesList"></div>
                                                <div class="documentsList"></div>
# ---
# To remove '-' lines, make …
Run Code Online (Sandbox Code Playgroud)

git

11
推荐指数
1
解决办法
4029
查看次数

使用git add --patch <filename>手动编辑

所以,我有一个我一直在分支A工作的文件,我只是准备提交它.但是,看看差异,我认为最好把它分成两个单独的提交(好吧,在这种情况下,可能是两个独立的分支).我之前使用过git add --patch来分离各个帅哥,所以我想我可以用它.问题是,我需要分开我的一个人.运行git add --patch SdA.py和使用e编辑问题块...

# Manual hunk edit mode -- see bottom for a quick guide
@@ -50,13 +50,74 @@ import PIL.Image as im

 import constant

+
+def exp_range(min=None, max=None, step=None):
+    """
+    Generate an exponentially increasing value scaled and offset such
+    that it covers the range (min, max].  Behaviour is similar to
+    exp(x), scaled such that the final value generated is equal to
+    'max'.  'step' defines the granularity of …
Run Code Online (Sandbox Code Playgroud)

git version-control git-add git-patch

7
推荐指数
1
解决办法
2603
查看次数

VSCode Git 退出并保存提交编辑器?

我在 Windows 10 上安装了 Git Bash,我正在关注这个关于在 VSCode 中使用 git 的视频https://youtu.be/MIFQwHlEI9o?t=602,他使用带 -p 选项的 checkout 从提交中挑选片段:

$ git checkout 0903304 index.html -p
diff --git b/index.html a/index.html
index 3ebbb46..d95bb1a 100644
--- b/index.html
+++ a/index.html
@@ -10,6 +10,10 @@
     <ul>
         <li>Item one</li>
     </ul>
+
+    <p>Paragraph one</p>
+    <h1>A title</h1>
+    <div><p>Some text</p></div>

 </body>
 </html>
\ No newline at end of file
Apply this hunk to index and worktree [y,n,q,a,d,e,?]
Run Code Online (Sandbox Code Playgroud)

当我输入“e”时,文件会加载两个版本,并且我的光标会自动放置在编辑器中。进行更改并按 CTRL+S 保存后,我无法退出。我尝试过 q、ESC、CTRL+X、wq、:wq、:x!除了用“x”关闭文件之外没有任何作用,但我得到:

Your edited hunk does not apply. Edit again …
Run Code Online (Sandbox Code Playgroud)

git visual-studio-code

4
推荐指数
1
解决办法
1万
查看次数