So the command to stage all changes for git is git add -A
.
Is there a way to execute this from within a repository subdirectory, and capture all changes anywhere in the repo, without having change the directory back to the repo root?
Example:
$pwd
/reporoot/
modify the file: /reporoot/a-file
$cd /a-subdir
$git 'magic variation of add -A which I'm looking for'
and the change to /reporoot/a-file will be staged.
I find that I'm often in one place in the terminal, but editing a file somewhere else with the IDE, so the answer to this question would be a helpful way for avoiding lots of cd'ing.
Use the following (only works in newer versions of Git):
git add $(git rev-parse --show-toplevel)
You may wish to create a Git alias for this to make running it easier.
Note that, if you plan on committing, doing the following will stage all changed files already in the working tree (i.e., not untracked files):
git commit -a
You are looking for
git add -u
, see the nice explanation here
Difference between "git add -A" and "git add ."
or the manual
http://git-scm.com/docs/git-add
. If you are going to commit next anyway, use git commit -a
as mentioned by Andrew.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With