Lets say I have a git root folder mine_git
, which has a subdirectory subdir
there. So I've worked a bit, and I'm in subdir
- git status
lists all changed files:
subdir$ git status -uno
# On branch master
# ...
#
# modified: mysubdirfile.txt
# modified: ../a-main-file.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
K, so I want to add all of these tracked and modified files to staging area (or cache? index? not sure of the name), so I can commit afterwards; so I issue:
subdir$ git add -u
... and then I check again:
subdir$ git status -uno
# On branch master
# Changes to be committed:
# ...
#
# modified: mysubdirfile.txt
#
# Changes not staged for commit:
# ...
#
# modified: ../a-main-file.txt
#
# Untracked files not listed (use -u option to show untracked files)
So, only those files under my current location are git add
ed, and not those in parent/sibling folders - even if those files are tracked by this git repository, and show up in git status
!
And then I usually have to manually copy paste filenames, so as to do git add ../a-main-file.txt
. Obviously this is a pain - so is there some command which will add all files listed by git status -uno
, regardless of if they are located below the current level or not?
The latest version of git (
2.4.3
) should do this already. Fromman 1 git-add
:That said, you could try something like
git add -u -- ../relative/path/to/project/root
. I don't have an older git version handy, so I could not test it.