ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying git for a programming project and It keeps saying that I have to "git add" all the files i've modified since the last commit, and it's getting on my nerves.
I am trying git for a programming project and It keeps saying that I have to "git add" all the files i've modified since the last commit, and it's getting on my nerves.
Is that really true? If so what's the purpose?
you cannot commit changes of unadded files. from your message, you alreaddy added to git repo. if so it shouldn't say this. however if names changed, then you have to ad them again. (for remaning, use git mv, it will handle the needed works).
I added those files before and did not change their names. I just modified their contents.
Code:
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Container.cpp I added these before!
# modified: Widget.cpp
# modified: Widget.h
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# main.cpp
no changes added to commit (use "git add" and/or "git commit -a")
I added those files before and did not change their names. I just modified their contents.
[...]
i tried similar thing on my wine git tree. now i modified the VERSION file and commited with git commit VERSION. no errors.
then i read git help commit. it will do git add then git commit. first adding to tree then committed (from DOCs (git help commit) Note: even modified files must bb "added"). this explains the behavior.
So "git commit -a" does what I want and does not add new files that I might not want version-controlled, right?
Yes, git commit -a is equivalent to svn commit (see Git - SVN Crash Course). Without the -a you have to do a git add for files that have changed.
Code:
man git-commit
...
OPTIONS
-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.
Quote:
Originally Posted by ozanbaba
do every file one by one. it's safer
I would recommend against checking in one file at a time if the changes are related.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.