LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   git question (https://www.linuxquestions.org/questions/programming-9/git-question-773451/)

MTK358 12-04-2009 08:20 AM

git question
 
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?

ozanbaba 12-04-2009 09:28 AM

Quote:

Originally Posted by MTK358 (Post 3779695)
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).

MTK358 12-04-2009 09:32 AM

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")


ozanbaba 12-04-2009 09:48 AM

Quote:

Originally Posted by MTK358 (Post 3779782)
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.

MTK358 12-04-2009 12:20 PM

So "git commit -a" does what I want and does not add new files that I might not want version-controlled, right?

ozanbaba 12-04-2009 12:50 PM

Quote:

Originally Posted by MTK358 (Post 3779985)
So "git commit -a" does what I want and does not add new files that I might not want version-controlled, right?

go file by file.

and use .gitignore for files should not be version controled

MTK358 12-04-2009 01:11 PM

Quote:

Originally Posted by ozanbaba (Post 3780012)
go file by file.


What does that mean?

ozanbaba 12-04-2009 01:14 PM

Quote:

Originally Posted by MTK358 (Post 3780026)
What does that mean?

do every file one by one. it's safer

MTK358 12-04-2009 01:54 PM

So I should remember every file I modified and add it before every commit? There really isn't an easier way?

ozanbaba 12-04-2009 02:21 PM

Quote:

Originally Posted by MTK358 (Post 3780070)
So I should remember every file I modified and add it before every commit? There really isn't an easier way?

commit do add automaticly and commit early commit offen. it makes changing between commits easier.

MTK358 12-04-2009 03:07 PM

If it adds automatically, then why would I be asking this?

ozanbaba 12-04-2009 03:56 PM

Quote:

Originally Posted by MTK358 (Post 3780136)
If it adds automatically, then why would I be asking this?

that's part i don't understand at all.

MTK358 12-04-2009 04:01 PM

I asked this question because for some reason modifying the contents of a file and running "git commit" did not commit the changes.

ntubski 12-04-2009 04:21 PM

Quote:

Originally Posted by MTK358 (Post 3779985)
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.

ozanbaba 12-04-2009 04:38 PM

Quote:

Originally Posted by ntubski (Post 3780224)
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.

funny it does not do that on my system. tree config spesific?


All times are GMT -5. The time now is 12:18 PM.