Search code examples
gitmsysgitgit-add

Add all files in git


I have this git status:

User#/d/Work/Project/Module1/NV/build (master)$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 3 commits.
#   (use "git push" to publish your local commits)
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   ../../Module1/CMakeLists.txt
#       modified:   ../../Module1/Container.cpp
#
no changes added to commit (use "git add" and/or "git commit -a")

How can I add the 2 files? git add -A doesn't work? I know it's possible to use the option git add ../../. for obvious reasons.

I know it's possible to add the files with a git add option but i can't remember it and I don't find it. I use git version 1.8.1.msysgit.1.


Solution

  • When I run git add -A from a subdirectory, my version of git (1.8.3.3) gives me this warning:

    warning: The behavior of 'git add --all (or -A)' with no path argument from a subdirectory of the tree will change in Git 2.0 and should not be used anymore. To add content for the whole tree, run:

    git add --all :/ (or git add -A :/)

    To restrict the command to the current directory, run:

    git add --all . (or git add -A .)

    With the current Git version, the command is restricted to the current directory.

    So what you're probably looking for is git add -A :/. You can easily create an alias for this with git config --global alias.addall 'add -A :/'.