LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-04-2009, 08:20 AM   #1
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
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?
 
Old 12-04-2009, 09:28 AM   #2
ozanbaba
Member
 
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 671

Rep: Reputation: 94
Quote:
Originally Posted by MTK358 View Post
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).
 
Old 12-04-2009, 09:32 AM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Original Poster
Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
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")
 
Old 12-04-2009, 09:48 AM   #4
ozanbaba
Member
 
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 671

Rep: Reputation: 94
Quote:
Originally Posted by MTK358 View Post
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.
 
Old 12-04-2009, 12:20 PM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Original Poster
Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
So "git commit -a" does what I want and does not add new files that I might not want version-controlled, right?
 
Old 12-04-2009, 12:50 PM   #6
ozanbaba
Member
 
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 671

Rep: Reputation: 94
Quote:
Originally Posted by MTK358 View Post
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
 
Old 12-04-2009, 01:11 PM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Original Poster
Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
Quote:
Originally Posted by ozanbaba View Post
go file by file.

What does that mean?
 
Old 12-04-2009, 01:14 PM   #8
ozanbaba
Member
 
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 671

Rep: Reputation: 94
Quote:
Originally Posted by MTK358 View Post
What does that mean?
do every file one by one. it's safer
 
0 members found this post helpful.
Old 12-04-2009, 01:54 PM   #9
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Original Poster
Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
So I should remember every file I modified and add it before every commit? There really isn't an easier way?
 
Old 12-04-2009, 02:21 PM   #10
ozanbaba
Member
 
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 671

Rep: Reputation: 94
Quote:
Originally Posted by MTK358 View Post
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.
 
0 members found this post helpful.
Old 12-04-2009, 03:07 PM   #11
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Original Poster
Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
If it adds automatically, then why would I be asking this?
 
Old 12-04-2009, 03:56 PM   #12
ozanbaba
Member
 
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 671

Rep: Reputation: 94
Quote:
Originally Posted by MTK358 View Post
If it adds automatically, then why would I be asking this?
that's part i don't understand at all.
 
Old 12-04-2009, 04:01 PM   #13
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Original Poster
Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
I asked this question because for some reason modifying the contents of a file and running "git commit" did not commit the changes.
 
Old 12-04-2009, 04:21 PM   #14
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,445

Rep: Reputation: 829Reputation: 829Reputation: 829Reputation: 829Reputation: 829Reputation: 829Reputation: 829
Quote:
Originally Posted by MTK358 View Post
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.
 
Old 12-04-2009, 04:38 PM   #15
ozanbaba
Member
 
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 671

Rep: Reputation: 94
Quote:
Originally Posted by ntubski View Post
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?
 
  


Reply

Tags
git


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help on GIT? your_shadow03 Linux - Server 1 03-20-2009 07:34 AM
why is git scm named 'git'? hottdogg Linux - General 5 02-03-2009 07:25 AM
Using GIT vkmgeek Linux - General 1 12-25-2008 04:48 PM
inconsistency issue of git-clone ***/git/mesa/drm with the existing kernel source centguy Linux - Desktop 2 10-08-2008 10:36 PM
git vkmgeek Linux - Newbie 2 06-19-2008 09:11 AM


All times are GMT -5. The time now is 11:59 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration