如何将我的 .vim 内容提交到 git 存储库

How can I commit my .vim contents to a git repo

当我最近开始学习 git 时,我认为将我所有的 .vim 内容放在 Github 上是个好主意(我的 vimrc 文件和我使用的脚本),当它们运行良好时提交,当它们运行不正常时进行重置。

一切正常,直到我对脚本进行了更改。不是我做的脚本,是我通过Vundle安装的脚本(准确的说是vim-trailing-whitespace)。我只是在脚本中更改了一些颜色名称,每次我执行 git status,它都会显示:

andre@andre:~/.vim$ git status
No ramo master
Changes not staged for commit:
  (utilize "git add <arquivo>..." para atualizar o que será submetido)
  (utilize "git checkout -- <arquivo>..." para descartar mudanças no diretório de trabalho)
  (submeter ou descartar o conteúdos não monitorados ou modificados em submódulos)

    modificado: bundle/vim-trailing-whitespace (conteúdo modificado)

nenhuma modificação adicionada à submissão (utilize "git add" e/ou "git commit -a")

git add .git add -A 之后我没有收到 return(我猜是正常的)。

但是在 git commit -m "Improved mapping, included saving with sudo tee in map, fixed indent lines" 之后我收到了同样的信息:

andre@andre:~/.vim$ sudo git commit -m "Improved mapping, included saving with sudo tee in map, fixed indent lines"
No ramo master
Changes not staged for commit:
    modificado: bundle/vim-trailing-whitespace (conteúdo modificado)

nenhuma modificação adicionada à submissão

那么,为什么我的 git add . 没有添加到舞台?我有一些线索,但没有答案。

编辑:

当我 运行 a git diff 我得到:

diff --git a/bundle/vim-trailing-whitespace b/bundle/vim-trailing-whitespace
--- a/bundle/vim-trailing-whitespace
+++ b/bundle/vim-trailing-whitespace
@@ -1 +1 @@
-Subproject commit 478b217d299b6f5938b43a4929d6bb0907cc3a56
+Subproject commit 478b217d299b6f5938b43a4929d6bb0907cc3a56-dirty

为什么会有这些子项目?我从不 "made" 它们,我只是用 Vundle 安装脚本。

tl;博士

实际上,这些步骤可能会解决您的问题(灵感来自 this):

git checkout -b tempbranch
git clone https://github.com/user/yourrepo --branch tempbranch
git checkout -b master
git update-ref HEAD master
git push --set-upstream origin master

关于 Vim 插件的提示

我认为将插件上传到您的存储库不是一个好主意。仅上传您的文件,如果您需要 运行 Vim 在另一台计算机上,请在 Vim.

中安装带有 :PluginInstall 的 Vundle 插件

如果您真的想将插件添加到您的存储库中,您可以考虑将它们添加为 git 个模块。

你的 Git

发生了什么

当谈到 Git 时,似乎 您缺少主分支 。根据this thread:

  • 当您拥有远程存储库时:

    To checkout branch which not exists locally but is in the remote repo you could use this command:

    git checkout -t -b master origin/master

  • 当您在本地工作时:

    Most Git repositories use master as the main (and default) branch - if you initialize a new Git repo via git init, it will have master checked out by default.

    或者你可以这样创建主分支:

    git checkout -b master