2013-10-18 41 views
1

我检出了一个现有分支,,并开始更改某些文件,并删除了一个。git commit,更改为现有文件的处理方式不同

做完git add .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 # 
+0

好的,我输入了'git commit -a',所有这些修改都被接受了。在此之前,我使用了'git add。'&'git commit' –

回答

1

如果我正确理解你的情况,你想提交包括一些现有的文件和删除一些其他修改。

您包含的输出看起来像git status在您想要删除的文件夹上试图执行git rm -r时会显示的内容。要包含其余的修改,您可以尝试执行git add -u,它会告诉Git包含您对提交进行的现有文件的所有更改。之后,执行git commit应同时提交您的修改和所需的文件删除。

另外,还要注意git commit -a(而不必使用git addgit rm以前)自动包括修改所有已知的文件,并指定清除所有文件的不再是你的工作目录。如果您需要澄清此link,请参阅手册页以提交命令。

1

'git add .'只会暂存当前文件夹及其下方的文件。
不是来自第14行至第17行的文件,位于另一个文件夹中。

git add(或缺失以及git add -A, starting git 2.0),而最后的点,将舞台从所有工作树中的文件。

而且我不会推荐git commit -a

  • 总是第一阶段(git add甚至git add -p到一个文件中添加块)
  • 检查状态(git status),请确保您实际想要的是上演。
  • 然后git commit
相关问题