Git - Automatically track all files in a directory

Possible duplicate:
git add -A, git commit in one command?

If I understand correctly when new files are added to the directory when using git, I have to call more than one command to make sure the files are committed:

git add <directory name> git commit -m 'commit comment' 

This is not so, because I know that I (and many others) will forget to call git add <directory name> and then finish the project, which does not git add <directory name> all the new files that were created. It seems that I should be able to commit the entire directory, including any and all new files, in one command, without specifying in the previous command to add all new files to commit. How to do it?

+6
source share
2 answers

get G2 at https://github.com/orefalo/g2

G2 helps you learn the git command line by providing easy-to-use macros.

g freeze -m "commit msg" command.

It works with additions, deletions and changes. you freeze a condition that was supposed to be one of the first.

+3
source

git commit -a will transfer all files known to git:

  -a, --all Tell the command to automatically stage files that have been modified and deleted, but new files you have not told git about are not affected. 

If you want to make sure that you are doing everything you want, you can use git-status prior to git-commit to view the files that were set to commit.

git uses a two-step process to get changes from the working directory to the repository . An approach like git commit -a will work, but it will result in erratic, non-atomic commits. I would advocate smaller, focused commits, rather than using a generic approach like the one you're looking for.

That doesn't sound right, because I know that I (and many others) will forget to call git add ...

git-status is your friend :)

Note. git-add does not add files to the repository. git commit writes things from the staging area repository , not from the working area . It may seem strange at first, but it gives you much more flexibility. See the other answer for more information.

+6
source

Source: https://habr.com/ru/post/916690/


All Articles