2

I'm trying to use git to manage my .emacs.d/ and I failed to add some files:

git add -A failed to add these files

And here is the .gitignore file:

*~
auto-save-list

Why git add -A failed to add these files? Any practical advice for managing .emacs.d with git?

Edit:

~/.emacs.d $ git config -l
user.email=nickleeh@hotmail.com
user.name=Nick Lee
core.autocrlf=input
core.editor=sublime -wl1
push.default=simple
color.ui=true
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
user.email=nickleeh@hotmail.com
~/.emacs.d $ 

Edit 2

When I try to add untracked files, I got this fatal error:

~/.emacs.d $ git add el-get/ace-jump-mode/*
fatal: Pathspec 'el-get/ace-jump-mode/README.md' is in submodule 'el-get/ace-jump-mode'

It turns out that ace-jump-mode is a submodule. How can I get ride of this?

Does that mean using git to manage emacs configuration files is not a good idea?

Nick
  • 8,451
  • 13
  • 57
  • 106

5 Answers5

2

According to http://git-scm.com/docs/git-add,

If no <pathspec> is given when -A option is used, all files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).

I assume this is your issue, although I do see one file that is in a sub-directory that was added.

Schwern
  • 153,029
  • 25
  • 195
  • 336
Joseph K. Strauss
  • 4,683
  • 1
  • 23
  • 40
1

You obviously already created at least two different repositories in the past.

One repository is located in ~/.emacs.d therefore git init does not create a fresh repository but only initializes it again:

From git help init:

   Running git init in an existing repository is safe. It will not
   overwrite things that are already there. The primary reason for
   rerunning git init is to pick up newly added templates (or to move the
   repository to another place if --separate-git-dir is given).

The other repository is located in ~/.emacs.d/el-get. This repository is the reason for the "untracked content" message and the reason for not adding these files to the outer repository.

You have three possibilities:

  • The inner repository was created by at tool and is managed by it: just ignore that directory in .gitignore.
  • The inner repository was created by mistake: remove the inner .git directory.
  • The inner repository was created manually on purpose: add it as a submodule to the outer repository.
michas
  • 25,361
  • 15
  • 76
  • 121
  • Thank you! I found out that `~/.emacs.d/el-get/` is a git repository created and managed by the emacs package management tool `el-get`. I don't want to get things complex. How to use git manage `.emacs.d` without breaking anything? – Nick Dec 28 '14 at 07:26
  • In that case you probably simply want to ignore that directory. (as el-get is already managing it.) – michas Dec 28 '14 at 07:33
0

Apparently Git now requires the path argument for the git add -A command...

Note that starting git 2.0 (Q1 or Q2 2014), when talking about git add . (current path within the working tree), you must use '.' in the other git add commands as well.

That means:

"git add -A ." is equivalent to "git add .; git add -u ."

(Note the extra '.' for git add -A and git add -u)

Because git add -A or git add -u would operate (starting git 2.0 only) on the entire working tree, and no just on the current path.

Community
  • 1
  • 1
Edward J Beckett
  • 5,061
  • 1
  • 41
  • 41
0

You should use

git add -u

To add all modified files that are already under version control. Otherwise, to add files that aren't already under control:

git add -A .
Adam Hughes
  • 14,601
  • 12
  • 83
  • 122
-1

It seems you have some sub-modules that have been modified but you have not committed those changes yet.

The first solution is to enter each one of those sub-modules and committing yourself the changes. Then you can git add -A in the parent repository and it will remove those messages.

Your second option is to use this:

git submodule foreach --recursive git add -A .

Which will commit everything in the submodules for you (but you lack control in this case).

More information in this link: git add -A is not adding all modified files in directories

Community
  • 1
  • 1
Daniel
  • 21,933
  • 14
  • 72
  • 101
  • That was a case of submodules; here, that is clearly no the case since the repository was just initialized. – Joseph K. Strauss Dec 28 '14 at 03:22
  • Not necessarily, if you look at his `git init` output you see that the repository existed already, so the `git init` won't do anything to existing submodules. (I just did the test myself and yup, `git init` respects submodules) – Daniel Dec 28 '14 at 03:36
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Lee Taylor Dec 28 '14 at 03:36
  • @LeeTaylor Thanks. I was assuming that as the link was inside StackOverflow it was safe. But I followed your recommendation now. – Daniel Dec 28 '14 at 03:43
  • @Mondkin You are right about the `git init`. I did not catch that is says reinitialized. However the other answer that you link to specifically mentions submodules in the `git status` outout, whereas this question does not provide any hint that there are submodules involved. – Joseph K. Strauss Dec 28 '14 at 03:44
  • @JosephK.Strauss Actually his `git status` output does state that submodules are involved: `(commit or discard the untracked or modified content in submodules)`. – Daniel Dec 28 '14 at 03:49
  • @Mondkin I stand corrected. I guess I should be getting some more sleep. – Joseph K. Strauss Dec 28 '14 at 03:52