0

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.

Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
  • 1
    You are in subdirectory. Why you can't do just this command? cd ../.. && git add . – cooperok Mar 04 '14 at 14:51
  • > no changes added to commit (use "git add" and/or "**git commit -a**")? – Ajedi32 Mar 04 '14 at 14:51
  • @cooperok I already said that `git add ../../.` is not an option. – Jacob Krieg Mar 04 '14 at 14:54
  • @Ajedi34 Did you read my question? I already sad that I tried `git add -A .`, and it does not work. I thought that it is obvious that `git add .` does not work. And I want to add the files not to commit them. – Jacob Krieg Mar 04 '14 at 14:56

2 Answers2

2

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 :/'.

Ajedi32
  • 45,670
  • 22
  • 127
  • 172
1

The rev-parse command can be used to find the root of your git project, you could then pass that into the git add command, like so:

git add $(git rev-parse --show-toplevel)
Graham Savage
  • 1,129
  • 13
  • 20