2

I am using Git version 1.9.1 and recently received this notice when making a commit on my repository:

warning: You ran 'git add' with neither '-A (--all)' or '--ignore-removal', whose behaviour will change in Git 2.0 with respect to paths you removed.

I usually commit changes by using these two commands:

git add .
git commit -a

I am now wondering whether I should switch to using --ignore-removal or -A. I read some of the other StackOverflow answers about this warning message, but I'm still not entirely clear on whether there would be any difference which option I use given that I'm immediately following it with git commit -a, which stages files for removal anyway.

My goal is to just have git automatically recognize all changes to a directory - additions, modifications, and deletions, and in fact I have an alias set up to do this in one command. I am currently leaning toward changing my alias to this:

git add -A .; git commit -a

Would that achieve my goal? My tentative understanding is that --ignore-removal would only be relevant in the case where I deleted some files but am not ready to commit those deletions to git yet - is that correct?


Thinking about this a bit more, I'm realizing I may not need the -a option on the commit command if I'm using -A on the add command, so how about this?

git add -A .; git commit

1 Answer 1

1

My goal is to just have git automatically recognize all changes to a directory - additions, modifications, and deletions

Good sir, this is also my goal. I accomplish this by

git add -A
git commit

or

git add -A foo.bar
git commit

The first form will do as you say, it will add any and all changes. The second form will only add changes to the specified file. I would add that commit -a is not necessary with my way either, because everything has already been staged with git add. I have been using this method for over a year now and it works well for me.

Example

Sign up to request clarification or add additional context in comments.

1 Comment

Update: for my alias, I changed it to git commit . rather than just git commit, so that it will work from subdirectories too. That way I can commit only the files in a particular subdirectory if I want without getting a warning from git ("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" etc...).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.