0

When I started learning git recently, I thought it would be a good idea to put all my .vim contents on Github (my vimrc file and the scripts I use), commiting then when they work well, and doing resets when they don't.

Everything worked fine until I did a change in a script. It's not a script made by me, it is a script I installed via Vundle (to be precise, the vim-trailing-whitespace). I just change some color name in the script, and everytime I do a git status, it shows:

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")

After a git add . or git add -A I receive no return (normal, I guess).

But after a git commit -m "Improved mapping, included saving with sudo tee in map, fixed indent lines" I receive the same:

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

So, why my git add . is not adding to stage? I have some clues, but no answer.

EDIT:

When I ran a git diff I get:

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

Why these subprojects are there? I never "made" them, I just install scripts with Vundle.

1 Answers1

1

tl;dr

Actually, these steps might solve your problem (inspired by 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

Tips on Vim plugins

I don't think that uploading plugins to your repo is a good idea. Upload only your files, and if you need to run Vim on a different computer then install your Vundle plugins with :PluginInstall inside Vim.

If you really want to add plugins to your repo, you might consider adding them as git modules.

What's happening with your Git

When it comes to Git it seems like you're missing the master branch. According to this thread:

  • When you have a remote repository:

    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

  • When you're working locally:

    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.

    Or you can create the master branch like this:

    git checkout -b master
    
Community
  • 1
  • 1
Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79
  • When I ran `git checkout -t -b master origin/master` I get: `fatal: A branch with the name 'master' already exists.` You see, I added some new stuff in my local machine and I pushed than easily. They're on my repository now. But the modified 'vim-trailing-whitespace' just don't want to go, it continues not staged. –  Jan 25 '16 at 04:21
  • The same described above. Check out the edit I did in the question... maybe it helps. –  Jan 25 '16 at 04:34
  • Subproject looks suspicious :) http://stackoverflow.com/questions/21088781/what-does-subproject-commit-mean – Mateusz Piotrowski Jan 25 '16 at 04:36
  • My guess (wild guess) is that when I install a script with Vundle it remains linked with the repository. In fact, I know that when the author update his/her script, Vundle automatically update it in my machine. So... I transformed my .vim folder in a local Git repository, changed a script and try to push it... maybe Github is saying "hey, you can't alter a script that is not yours." With this explanation you can see I really don't understand Git a lot XD. But... maybe I'm right? –  Jan 25 '16 at 04:40
  • Well, certainly something is messed up here. However I don't know much about submodules yet, so I cannot help you more with this particular issue. For the time being, I recommend you not to push everything to your GitHub repo - it is muuuch better to keep your plugins being managed by Vundle. – Mateusz Piotrowski Jan 25 '16 at 04:43