1

我检查了一个现有的分支,课程,并开始更改一些文件,并删除了一个。

在执行git add .and之后git commit,提交了一些更改,但其他更改在注释文本的末尾分开。据我了解,我必须手动进行一些操作。

所以,对于我删除的文件git rm file.name。我得到了这个部分。

我应该如何处理第 14-17 行?

所有这些文件都是更早创建的,没有新的。

非常感谢!

  1 
  2 # Please enter the commit message for your changes. Lines starting
  3 # with '#' will be ignored, and an empty message aborts the commit.
  4 # On branch lessons
  5 # Changes to be committed:
  6 #   (use "git reset HEAD <file>..." to unstage)
  7 #
  8   deleted:    ../layouts/]
  9 #
 10 # Changes not staged for commit:
 11 #   (use "git add <file>..." to update what will be committed)
 12 #   (use "git checkout -- <file>..." to discard changes in working directory)
 13 #
 14 # modified:   ../courses/show.html.slim                                                                                                   
 15 # modified:   ../layouts/_header.html.slim
 16 # modified:   ../student_levels/_student_level.html.slim
 17 # modified:   ../subjects/_subject.html.slim
 18 #
4

2 回答 2

1

If I understand your situation correctly, the commit you want to make consists of modifications on some existing files and removal of some others.

The output that you have included looks like what git status would show if you tried to execute git rm -r on the folder you wanted to delete. To include the rest of your modifications you can try executing git add -u, which tells Git include to all changes to existing files that you have made into the commit. After that, executing a git commit should commit both your modifications and desired removal of files.

Also, note that git commit -a (without having used git add or git rm previously) automatically includes modifications to all known files and also specifies removal of all files no longer in your working directory. See the manual page for the commit command if you need clarification at this link.

于 2013-10-18T05:38:36.087 回答
1

' git add .' 只会暂存当前文件夹及以下文件夹中的文件。
不是第 14 行到第 17 行的文件,它们位于另一个文件夹中。

git add(或者对于删除git add -A,从 git 2.0 开始),没有最后一个点,将从所有工作树中暂存文件。

我不推荐git commit -a

  • 总是先阶段(git add甚至git add -p在文件中添加块)
  • 检查您的状态 ( git status),确保您真正想要的已上演。
  • 然后 git commit
于 2013-10-18T06:30:13.407 回答