I apologize if my question is about a very simple topic, and it is answered elsewhere, but I’m a noob with git, and I couldn’t answer it neither reading the git documentation, nor searching the web.
I’ve created a git repository for a simple test project. I initialized the repository, added some files and directories using some git add commands, and made my first commit.
Just suppose, for example, I’ve added a README and two directories, src1 and src2, which contain some files. Then suppose I’ve not just edited the file contents, but I’ve added/removed files in these directories. In order to make the repo up-to-date, I’m currently doing:
git add --update
git add src1 src2
git commit -m "something"
Please note I’m updating the edited files, and removing the deleted files with git add --update and then re-adding the two directories in order to make git track the new files created into them! Is there a simple way (without re-adding) of doing this? I’ve tried with just:
git add --update
git commit -m "something"
but this won’t add new files that have been created under src1 and src2 directories. That’s because git doesn’t “remember” I’m tracking an entire directory, but just the files within. git doesn’t seem to track directories.
Obviously I’ve created a bash script with the lines you see in the above example, but it is a bit cumbersome and I would like to know if there’s an easier method.
Instead of
--update, use--all. See man git-addThats very easy to explain: Yes, you are right 🙂 Git doesn’t track directories at all, because directories are not objects in the git-world. Directories don’t have any content and there will never be changes to them (because of the missing content), that can git track. If you call
git add path/to/directorythis will not add the directory, but it will add every containing file recursivly.Just a hint: TIG helped me starting with git quite much 🙂